4 * Copyright (c) 2005 Samuel Tardieu
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.1 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, see <http://www.gnu.org/licenses/>.
20 #include "qemu/osdep.h"
23 #include "exec/exec-all.h"
26 #if !defined(CONFIG_USER_ONLY)
27 #include "hw/sh4/sh_intc.h"
28 #include "sysemu/runstate.h"
32 #define MMU_ITLB_MISS (-1)
33 #define MMU_ITLB_MULTIPLE (-2)
34 #define MMU_ITLB_VIOLATION (-3)
35 #define MMU_DTLB_MISS_READ (-4)
36 #define MMU_DTLB_MISS_WRITE (-5)
37 #define MMU_DTLB_INITIAL_WRITE (-6)
38 #define MMU_DTLB_VIOLATION_READ (-7)
39 #define MMU_DTLB_VIOLATION_WRITE (-8)
40 #define MMU_DTLB_MULTIPLE (-9)
41 #define MMU_DTLB_MISS (-10)
42 #define MMU_IADDR_ERROR (-11)
43 #define MMU_DADDR_ERROR_READ (-12)
44 #define MMU_DADDR_ERROR_WRITE (-13)
46 #if defined(CONFIG_USER_ONLY)
48 int cpu_sh4_is_cached(CPUSH4State
*env
, target_ulong addr
)
50 /* For user mode, only U0 area is cacheable. */
51 return !(addr
& 0x80000000);
54 #else /* !CONFIG_USER_ONLY */
56 void superh_cpu_do_interrupt(CPUState
*cs
)
58 SuperHCPU
*cpu
= SUPERH_CPU(cs
);
59 CPUSH4State
*env
= &cpu
->env
;
60 int do_irq
= cs
->interrupt_request
& CPU_INTERRUPT_HARD
;
61 int do_exp
, irq_vector
= cs
->exception_index
;
63 /* prioritize exceptions over interrupts */
65 do_exp
= cs
->exception_index
!= -1;
66 do_irq
= do_irq
&& (cs
->exception_index
== -1);
68 if (env
->sr
& (1u << SR_BL
)) {
69 if (do_exp
&& cs
->exception_index
!= 0x1e0) {
70 /* In theory a masked exception generates a reset exception,
71 which in turn jumps to the reset vector. However this only
72 works when using a bootloader. When using a kernel and an
73 initrd, they need to be reloaded and the program counter
74 should be loaded with the kernel entry point.
75 qemu_system_reset_request takes care of that. */
76 qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET
);
79 if (do_irq
&& !env
->in_sleep
) {
86 irq_vector
= sh_intc_get_pending_vector(env
->intc_handle
,
87 (env
->sr
>> 4) & 0xf);
88 if (irq_vector
== -1) {
93 if (qemu_loglevel_mask(CPU_LOG_INT
)) {
95 switch (cs
->exception_index
) {
97 expname
= "addr_error";
100 expname
= "tlb_miss";
103 expname
= "tlb_violation";
106 expname
= "illegal_instruction";
109 expname
= "slot_illegal_instruction";
112 expname
= "fpu_disable";
115 expname
= "slot_fpu";
118 expname
= "data_write";
121 expname
= "dtlb_miss_write";
124 expname
= "dtlb_violation_write";
127 expname
= "fpu_exception";
130 expname
= "initial_page_write";
136 expname
= do_irq
? "interrupt" : "???";
139 qemu_log("exception 0x%03x [%s] raised\n",
140 irq_vector
, expname
);
141 log_cpu_state(cs
, 0);
144 env
->ssr
= cpu_read_sr(env
);
146 env
->sgr
= env
->gregs
[15];
147 env
->sr
|= (1u << SR_BL
) | (1u << SR_MD
) | (1u << SR_RB
);
150 if (env
->flags
& DELAY_SLOT_MASK
) {
151 /* Branch instruction should be executed again before delay slot. */
153 /* Clear flags for exception/interrupt routine. */
154 env
->flags
&= ~DELAY_SLOT_MASK
;
158 env
->expevt
= cs
->exception_index
;
159 switch (cs
->exception_index
) {
163 env
->sr
&= ~(1u << SR_FD
);
164 env
->sr
|= 0xf << 4; /* IMASK */
165 env
->pc
= 0xa0000000;
169 env
->pc
= env
->vbr
+ 0x400;
172 env
->spc
+= 2; /* special case for TRAPA */
175 env
->pc
= env
->vbr
+ 0x100;
182 env
->intevt
= irq_vector
;
183 env
->pc
= env
->vbr
+ 0x600;
188 static void update_itlb_use(CPUSH4State
* env
, int itlbnb
)
190 uint8_t or_mask
= 0, and_mask
= (uint8_t) - 1;
209 env
->mmucr
&= (and_mask
<< 24) | 0x00ffffff;
210 env
->mmucr
|= (or_mask
<< 24);
213 static int itlb_replacement(CPUSH4State
* env
)
215 if ((env
->mmucr
& 0xe0000000) == 0xe0000000) {
218 if ((env
->mmucr
& 0x98000000) == 0x18000000) {
221 if ((env
->mmucr
& 0x54000000) == 0x04000000) {
224 if ((env
->mmucr
& 0x2c000000) == 0x00000000) {
227 cpu_abort(env_cpu(env
), "Unhandled itlb_replacement");
230 /* Find the corresponding entry in the right TLB
231 Return entry, MMU_DTLB_MISS or MMU_DTLB_MULTIPLE
233 static int find_tlb_entry(CPUSH4State
* env
, target_ulong address
,
234 tlb_t
* entries
, uint8_t nbtlb
, int use_asid
)
236 int match
= MMU_DTLB_MISS
;
241 asid
= env
->pteh
& 0xff;
243 for (i
= 0; i
< nbtlb
; i
++) {
245 continue; /* Invalid entry */
246 if (!entries
[i
].sh
&& use_asid
&& entries
[i
].asid
!= asid
)
247 continue; /* Bad ASID */
248 start
= (entries
[i
].vpn
<< 10) & ~(entries
[i
].size
- 1);
249 end
= start
+ entries
[i
].size
- 1;
250 if (address
>= start
&& address
<= end
) { /* Match */
251 if (match
!= MMU_DTLB_MISS
)
252 return MMU_DTLB_MULTIPLE
; /* Multiple match */
259 static void increment_urc(CPUSH4State
* env
)
264 urb
= ((env
->mmucr
) >> 18) & 0x3f;
265 urc
= ((env
->mmucr
) >> 10) & 0x3f;
267 if ((urb
> 0 && urc
> urb
) || urc
> (UTLB_SIZE
- 1))
269 env
->mmucr
= (env
->mmucr
& 0xffff03ff) | (urc
<< 10);
272 /* Copy and utlb entry into itlb
275 static int copy_utlb_entry_itlb(CPUSH4State
*env
, int utlb
)
280 itlb
= itlb_replacement(env
);
281 ientry
= &env
->itlb
[itlb
];
283 tlb_flush_page(env_cpu(env
), ientry
->vpn
<< 10);
285 *ientry
= env
->utlb
[utlb
];
286 update_itlb_use(env
, itlb
);
291 Return entry, MMU_ITLB_MISS, MMU_ITLB_MULTIPLE or MMU_DTLB_MULTIPLE
293 static int find_itlb_entry(CPUSH4State
* env
, target_ulong address
,
298 e
= find_tlb_entry(env
, address
, env
->itlb
, ITLB_SIZE
, use_asid
);
299 if (e
== MMU_DTLB_MULTIPLE
) {
300 e
= MMU_ITLB_MULTIPLE
;
301 } else if (e
== MMU_DTLB_MISS
) {
304 update_itlb_use(env
, e
);
310 Return entry, MMU_DTLB_MISS, MMU_DTLB_MULTIPLE */
311 static int find_utlb_entry(CPUSH4State
* env
, target_ulong address
, int use_asid
)
313 /* per utlb access */
317 return find_tlb_entry(env
, address
, env
->utlb
, UTLB_SIZE
, use_asid
);
320 /* Match address against MMU
321 Return MMU_OK, MMU_DTLB_MISS_READ, MMU_DTLB_MISS_WRITE,
322 MMU_DTLB_INITIAL_WRITE, MMU_DTLB_VIOLATION_READ,
323 MMU_DTLB_VIOLATION_WRITE, MMU_ITLB_MISS,
324 MMU_ITLB_MULTIPLE, MMU_ITLB_VIOLATION,
325 MMU_IADDR_ERROR, MMU_DADDR_ERROR_READ, MMU_DADDR_ERROR_WRITE.
327 static int get_mmu_address(CPUSH4State
* env
, target_ulong
* physical
,
328 int *prot
, target_ulong address
,
329 MMUAccessType access_type
)
332 tlb_t
*matching
= NULL
;
334 use_asid
= !(env
->mmucr
& MMUCR_SV
) || !(env
->sr
& (1u << SR_MD
));
336 if (access_type
== MMU_INST_FETCH
) {
337 n
= find_itlb_entry(env
, address
, use_asid
);
339 matching
= &env
->itlb
[n
];
340 if (!(env
->sr
& (1u << SR_MD
)) && !(matching
->pr
& 2)) {
341 n
= MMU_ITLB_VIOLATION
;
346 n
= find_utlb_entry(env
, address
, use_asid
);
348 n
= copy_utlb_entry_itlb(env
, n
);
349 matching
= &env
->itlb
[n
];
350 if (!(env
->sr
& (1u << SR_MD
)) && !(matching
->pr
& 2)) {
351 n
= MMU_ITLB_VIOLATION
;
353 *prot
= PAGE_READ
| PAGE_EXEC
;
354 if ((matching
->pr
& 1) && matching
->d
) {
358 } else if (n
== MMU_DTLB_MULTIPLE
) {
359 n
= MMU_ITLB_MULTIPLE
;
360 } else if (n
== MMU_DTLB_MISS
) {
365 n
= find_utlb_entry(env
, address
, use_asid
);
367 matching
= &env
->utlb
[n
];
368 if (!(env
->sr
& (1u << SR_MD
)) && !(matching
->pr
& 2)) {
369 n
= (access_type
== MMU_DATA_STORE
)
370 ? MMU_DTLB_VIOLATION_WRITE
: MMU_DTLB_VIOLATION_READ
;
371 } else if ((access_type
== MMU_DATA_STORE
) && !(matching
->pr
& 1)) {
372 n
= MMU_DTLB_VIOLATION_WRITE
;
373 } else if ((access_type
== MMU_DATA_STORE
) && !matching
->d
) {
374 n
= MMU_DTLB_INITIAL_WRITE
;
377 if ((matching
->pr
& 1) && matching
->d
) {
381 } else if (n
== MMU_DTLB_MISS
) {
382 n
= (access_type
== MMU_DATA_STORE
)
383 ? MMU_DTLB_MISS_WRITE
: MMU_DTLB_MISS_READ
;
388 *physical
= ((matching
->ppn
<< 10) & ~(matching
->size
- 1))
389 | (address
& (matching
->size
- 1));
394 static int get_physical_address(CPUSH4State
* env
, target_ulong
* physical
,
395 int *prot
, target_ulong address
,
396 MMUAccessType access_type
)
398 /* P1, P2 and P4 areas do not use translation */
399 if ((address
>= 0x80000000 && address
< 0xc0000000) || address
>= 0xe0000000) {
400 if (!(env
->sr
& (1u << SR_MD
))
401 && (address
< 0xe0000000 || address
>= 0xe4000000)) {
402 /* Unauthorized access in user mode (only store queues are available) */
403 qemu_log_mask(LOG_GUEST_ERROR
, "Unauthorized access\n");
404 if (access_type
== MMU_DATA_LOAD
) {
405 return MMU_DADDR_ERROR_READ
;
406 } else if (access_type
== MMU_DATA_STORE
) {
407 return MMU_DADDR_ERROR_WRITE
;
409 return MMU_IADDR_ERROR
;
412 if (address
>= 0x80000000 && address
< 0xc0000000) {
413 /* Mask upper 3 bits for P1 and P2 areas */
414 *physical
= address
& 0x1fffffff;
418 *prot
= PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
;
422 /* If MMU is disabled, return the corresponding physical page */
423 if (!(env
->mmucr
& MMUCR_AT
)) {
424 *physical
= address
& 0x1FFFFFFF;
425 *prot
= PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
;
429 /* We need to resort to the MMU */
430 return get_mmu_address(env
, physical
, prot
, address
, access_type
);
433 hwaddr
superh_cpu_get_phys_page_debug(CPUState
*cs
, vaddr addr
)
435 SuperHCPU
*cpu
= SUPERH_CPU(cs
);
436 target_ulong physical
;
439 if (get_physical_address(&cpu
->env
, &physical
, &prot
, addr
, MMU_DATA_LOAD
)
447 void cpu_load_tlb(CPUSH4State
* env
)
449 CPUState
*cs
= env_cpu(env
);
450 int n
= cpu_mmucr_urc(env
->mmucr
);
451 tlb_t
* entry
= &env
->utlb
[n
];
454 /* Overwriting valid entry in utlb. */
455 target_ulong address
= entry
->vpn
<< 10;
456 tlb_flush_page(cs
, address
);
459 /* Take values into cpu status from registers. */
460 entry
->asid
= (uint8_t)cpu_pteh_asid(env
->pteh
);
461 entry
->vpn
= cpu_pteh_vpn(env
->pteh
);
462 entry
->v
= (uint8_t)cpu_ptel_v(env
->ptel
);
463 entry
->ppn
= cpu_ptel_ppn(env
->ptel
);
464 entry
->sz
= (uint8_t)cpu_ptel_sz(env
->ptel
);
467 entry
->size
= 1024; /* 1K */
470 entry
->size
= 1024 * 4; /* 4K */
473 entry
->size
= 1024 * 64; /* 64K */
476 entry
->size
= 1024 * 1024; /* 1M */
479 cpu_abort(cs
, "Unhandled load_tlb");
482 entry
->sh
= (uint8_t)cpu_ptel_sh(env
->ptel
);
483 entry
->c
= (uint8_t)cpu_ptel_c(env
->ptel
);
484 entry
->pr
= (uint8_t)cpu_ptel_pr(env
->ptel
);
485 entry
->d
= (uint8_t)cpu_ptel_d(env
->ptel
);
486 entry
->wt
= (uint8_t)cpu_ptel_wt(env
->ptel
);
487 entry
->sa
= (uint8_t)cpu_ptea_sa(env
->ptea
);
488 entry
->tc
= (uint8_t)cpu_ptea_tc(env
->ptea
);
491 void cpu_sh4_invalidate_tlb(CPUSH4State
*s
)
496 for (i
= 0; i
< UTLB_SIZE
; i
++) {
497 tlb_t
* entry
= &s
->utlb
[i
];
501 for (i
= 0; i
< ITLB_SIZE
; i
++) {
502 tlb_t
* entry
= &s
->itlb
[i
];
506 tlb_flush(env_cpu(s
));
509 uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State
*s
,
512 int index
= (addr
& 0x00000300) >> 8;
513 tlb_t
* entry
= &s
->itlb
[index
];
515 return (entry
->vpn
<< 10) |
520 void cpu_sh4_write_mmaped_itlb_addr(CPUSH4State
*s
, hwaddr addr
,
523 uint32_t vpn
= (mem_value
& 0xfffffc00) >> 10;
524 uint8_t v
= (uint8_t)((mem_value
& 0x00000100) >> 8);
525 uint8_t asid
= (uint8_t)(mem_value
& 0x000000ff);
527 int index
= (addr
& 0x00000300) >> 8;
528 tlb_t
* entry
= &s
->itlb
[index
];
530 /* Overwriting valid entry in itlb. */
531 target_ulong address
= entry
->vpn
<< 10;
532 tlb_flush_page(env_cpu(s
), address
);
539 uint32_t cpu_sh4_read_mmaped_itlb_data(CPUSH4State
*s
,
542 int array
= (addr
& 0x00800000) >> 23;
543 int index
= (addr
& 0x00000300) >> 8;
544 tlb_t
* entry
= &s
->itlb
[index
];
547 /* ITLB Data Array 1 */
548 return (entry
->ppn
<< 10) |
551 ((entry
->sz
& 1) << 6) |
552 ((entry
->sz
& 2) << 4) |
556 /* ITLB Data Array 2 */
557 return (entry
->tc
<< 1) |
562 void cpu_sh4_write_mmaped_itlb_data(CPUSH4State
*s
, hwaddr addr
,
565 int array
= (addr
& 0x00800000) >> 23;
566 int index
= (addr
& 0x00000300) >> 8;
567 tlb_t
* entry
= &s
->itlb
[index
];
570 /* ITLB Data Array 1 */
572 /* Overwriting valid entry in utlb. */
573 target_ulong address
= entry
->vpn
<< 10;
574 tlb_flush_page(env_cpu(s
), address
);
576 entry
->ppn
= (mem_value
& 0x1ffffc00) >> 10;
577 entry
->v
= (mem_value
& 0x00000100) >> 8;
578 entry
->sz
= (mem_value
& 0x00000080) >> 6 |
579 (mem_value
& 0x00000010) >> 4;
580 entry
->pr
= (mem_value
& 0x00000040) >> 5;
581 entry
->c
= (mem_value
& 0x00000008) >> 3;
582 entry
->sh
= (mem_value
& 0x00000002) >> 1;
584 /* ITLB Data Array 2 */
585 entry
->tc
= (mem_value
& 0x00000008) >> 3;
586 entry
->sa
= (mem_value
& 0x00000007);
590 uint32_t cpu_sh4_read_mmaped_utlb_addr(CPUSH4State
*s
,
593 int index
= (addr
& 0x00003f00) >> 8;
594 tlb_t
* entry
= &s
->utlb
[index
];
596 increment_urc(s
); /* per utlb access */
598 return (entry
->vpn
<< 10) |
603 void cpu_sh4_write_mmaped_utlb_addr(CPUSH4State
*s
, hwaddr addr
,
606 int associate
= addr
& 0x0000080;
607 uint32_t vpn
= (mem_value
& 0xfffffc00) >> 10;
608 uint8_t d
= (uint8_t)((mem_value
& 0x00000200) >> 9);
609 uint8_t v
= (uint8_t)((mem_value
& 0x00000100) >> 8);
610 uint8_t asid
= (uint8_t)(mem_value
& 0x000000ff);
611 int use_asid
= !(s
->mmucr
& MMUCR_SV
) || !(s
->sr
& (1u << SR_MD
));
615 tlb_t
* utlb_match_entry
= NULL
;
616 int needs_tlb_flush
= 0;
619 for (i
= 0; i
< UTLB_SIZE
; i
++) {
620 tlb_t
* entry
= &s
->utlb
[i
];
624 if (entry
->vpn
== vpn
625 && (!use_asid
|| entry
->asid
== asid
|| entry
->sh
)) {
626 if (utlb_match_entry
) {
627 CPUState
*cs
= env_cpu(s
);
629 /* Multiple TLB Exception */
630 cs
->exception_index
= 0x140;
638 utlb_match_entry
= entry
;
640 increment_urc(s
); /* per utlb access */
644 for (i
= 0; i
< ITLB_SIZE
; i
++) {
645 tlb_t
* entry
= &s
->itlb
[i
];
646 if (entry
->vpn
== vpn
647 && (!use_asid
|| entry
->asid
== asid
|| entry
->sh
)) {
650 if (utlb_match_entry
)
651 *entry
= *utlb_match_entry
;
658 if (needs_tlb_flush
) {
659 tlb_flush_page(env_cpu(s
), vpn
<< 10);
662 int index
= (addr
& 0x00003f00) >> 8;
663 tlb_t
* entry
= &s
->utlb
[index
];
665 CPUState
*cs
= env_cpu(s
);
667 /* Overwriting valid entry in utlb. */
668 target_ulong address
= entry
->vpn
<< 10;
669 tlb_flush_page(cs
, address
);
679 uint32_t cpu_sh4_read_mmaped_utlb_data(CPUSH4State
*s
,
682 int array
= (addr
& 0x00800000) >> 23;
683 int index
= (addr
& 0x00003f00) >> 8;
684 tlb_t
* entry
= &s
->utlb
[index
];
686 increment_urc(s
); /* per utlb access */
689 /* ITLB Data Array 1 */
690 return (entry
->ppn
<< 10) |
693 ((entry
->sz
& 1) << 6) |
694 ((entry
->sz
& 2) << 4) |
700 /* ITLB Data Array 2 */
701 return (entry
->tc
<< 1) |
706 void cpu_sh4_write_mmaped_utlb_data(CPUSH4State
*s
, hwaddr addr
,
709 int array
= (addr
& 0x00800000) >> 23;
710 int index
= (addr
& 0x00003f00) >> 8;
711 tlb_t
* entry
= &s
->utlb
[index
];
713 increment_urc(s
); /* per utlb access */
716 /* UTLB Data Array 1 */
718 /* Overwriting valid entry in utlb. */
719 target_ulong address
= entry
->vpn
<< 10;
720 tlb_flush_page(env_cpu(s
), address
);
722 entry
->ppn
= (mem_value
& 0x1ffffc00) >> 10;
723 entry
->v
= (mem_value
& 0x00000100) >> 8;
724 entry
->sz
= (mem_value
& 0x00000080) >> 6 |
725 (mem_value
& 0x00000010) >> 4;
726 entry
->pr
= (mem_value
& 0x00000060) >> 5;
727 entry
->c
= (mem_value
& 0x00000008) >> 3;
728 entry
->d
= (mem_value
& 0x00000004) >> 2;
729 entry
->sh
= (mem_value
& 0x00000002) >> 1;
730 entry
->wt
= (mem_value
& 0x00000001);
732 /* UTLB Data Array 2 */
733 entry
->tc
= (mem_value
& 0x00000008) >> 3;
734 entry
->sa
= (mem_value
& 0x00000007);
738 int cpu_sh4_is_cached(CPUSH4State
* env
, target_ulong addr
)
741 int use_asid
= !(env
->mmucr
& MMUCR_SV
) || !(env
->sr
& (1u << SR_MD
));
744 if (env
->sr
& (1u << SR_MD
)) {
745 /* For privileged mode, P2 and P4 area is not cacheable. */
746 if ((0xA0000000 <= addr
&& addr
< 0xC0000000) || 0xE0000000 <= addr
)
749 /* For user mode, only U0 area is cacheable. */
750 if (0x80000000 <= addr
)
755 * TODO : Evaluate CCR and check if the cache is on or off.
756 * Now CCR is not in CPUSH4State, but in SH7750State.
757 * When you move the ccr into CPUSH4State, the code will be
761 /* check if operand cache is enabled or not. */
766 /* if MMU is off, no check for TLB. */
767 if (env
->mmucr
& MMUCR_AT
)
771 n
= find_tlb_entry(env
, addr
, env
->itlb
, ITLB_SIZE
, use_asid
);
773 return env
->itlb
[n
].c
;
775 n
= find_tlb_entry(env
, addr
, env
->utlb
, UTLB_SIZE
, use_asid
);
777 return env
->utlb
[n
].c
;
782 bool superh_cpu_exec_interrupt(CPUState
*cs
, int interrupt_request
)
784 if (interrupt_request
& CPU_INTERRUPT_HARD
) {
785 SuperHCPU
*cpu
= SUPERH_CPU(cs
);
786 CPUSH4State
*env
= &cpu
->env
;
788 /* Delay slots are indivisible, ignore interrupts */
789 if (env
->flags
& DELAY_SLOT_MASK
) {
792 superh_cpu_do_interrupt(cs
);
799 bool superh_cpu_tlb_fill(CPUState
*cs
, vaddr address
, int size
,
800 MMUAccessType access_type
, int mmu_idx
,
801 bool probe
, uintptr_t retaddr
)
803 SuperHCPU
*cpu
= SUPERH_CPU(cs
);
804 CPUSH4State
*env
= &cpu
->env
;
807 target_ulong physical
;
810 ret
= get_physical_address(env
, &physical
, &prot
, address
, access_type
);
813 address
&= TARGET_PAGE_MASK
;
814 physical
&= TARGET_PAGE_MASK
;
815 tlb_set_page(cs
, address
, physical
, prot
, mmu_idx
, TARGET_PAGE_SIZE
);
822 if (ret
!= MMU_DTLB_MULTIPLE
&& ret
!= MMU_ITLB_MULTIPLE
) {
823 env
->pteh
= (env
->pteh
& PTEH_ASID_MASK
) | (address
& PTEH_VPN_MASK
);
829 case MMU_DTLB_MISS_READ
:
830 cs
->exception_index
= 0x040;
832 case MMU_DTLB_MULTIPLE
:
833 case MMU_ITLB_MULTIPLE
:
834 cs
->exception_index
= 0x140;
836 case MMU_ITLB_VIOLATION
:
837 cs
->exception_index
= 0x0a0;
839 case MMU_DTLB_MISS_WRITE
:
840 cs
->exception_index
= 0x060;
842 case MMU_DTLB_INITIAL_WRITE
:
843 cs
->exception_index
= 0x080;
845 case MMU_DTLB_VIOLATION_READ
:
846 cs
->exception_index
= 0x0a0;
848 case MMU_DTLB_VIOLATION_WRITE
:
849 cs
->exception_index
= 0x0c0;
851 case MMU_IADDR_ERROR
:
852 case MMU_DADDR_ERROR_READ
:
853 cs
->exception_index
= 0x0e0;
855 case MMU_DADDR_ERROR_WRITE
:
856 cs
->exception_index
= 0x100;
859 cpu_abort(cs
, "Unhandled MMU fault");
861 cpu_loop_exit_restore(cs
, retaddr
);
863 #endif /* !CONFIG_USER_ONLY */