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 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-common.h"
23 #if !defined(CONFIG_USER_ONLY)
24 #include "hw/sh4/sh_intc.h"
27 #if defined(CONFIG_USER_ONLY)
29 void superh_cpu_do_interrupt(CPUState
*cs
)
31 cs
->exception_index
= -1;
34 int superh_cpu_handle_mmu_fault(CPUState
*cs
, vaddr address
, int rw
,
37 SuperHCPU
*cpu
= SUPERH_CPU(cs
);
38 CPUSH4State
*env
= &cpu
->env
;
41 cs
->exception_index
= -1;
44 cs
->exception_index
= 0x0a0;
47 cs
->exception_index
= 0x0c0;
50 cs
->exception_index
= 0x0a0;
56 int cpu_sh4_is_cached(CPUSH4State
* env
, target_ulong addr
)
58 /* For user mode, only U0 area is cachable. */
59 return !(addr
& 0x80000000);
62 #else /* !CONFIG_USER_ONLY */
65 #define MMU_ITLB_MISS (-1)
66 #define MMU_ITLB_MULTIPLE (-2)
67 #define MMU_ITLB_VIOLATION (-3)
68 #define MMU_DTLB_MISS_READ (-4)
69 #define MMU_DTLB_MISS_WRITE (-5)
70 #define MMU_DTLB_INITIAL_WRITE (-6)
71 #define MMU_DTLB_VIOLATION_READ (-7)
72 #define MMU_DTLB_VIOLATION_WRITE (-8)
73 #define MMU_DTLB_MULTIPLE (-9)
74 #define MMU_DTLB_MISS (-10)
75 #define MMU_IADDR_ERROR (-11)
76 #define MMU_DADDR_ERROR_READ (-12)
77 #define MMU_DADDR_ERROR_WRITE (-13)
79 void superh_cpu_do_interrupt(CPUState
*cs
)
81 SuperHCPU
*cpu
= SUPERH_CPU(cs
);
82 CPUSH4State
*env
= &cpu
->env
;
83 int do_irq
= cs
->interrupt_request
& CPU_INTERRUPT_HARD
;
84 int do_exp
, irq_vector
= cs
->exception_index
;
86 /* prioritize exceptions over interrupts */
88 do_exp
= cs
->exception_index
!= -1;
89 do_irq
= do_irq
&& (cs
->exception_index
== -1);
91 if (env
->sr
& SR_BL
) {
92 if (do_exp
&& cs
->exception_index
!= 0x1e0) {
93 cs
->exception_index
= 0x000; /* masked exception -> reset */
95 if (do_irq
&& !env
->in_sleep
) {
102 irq_vector
= sh_intc_get_pending_vector(env
->intc_handle
,
103 (env
->sr
>> 4) & 0xf);
104 if (irq_vector
== -1) {
109 if (qemu_loglevel_mask(CPU_LOG_INT
)) {
111 switch (cs
->exception_index
) {
113 expname
= "addr_error";
116 expname
= "tlb_miss";
119 expname
= "tlb_violation";
122 expname
= "illegal_instruction";
125 expname
= "slot_illegal_instruction";
128 expname
= "fpu_disable";
131 expname
= "slot_fpu";
134 expname
= "data_write";
137 expname
= "dtlb_miss_write";
140 expname
= "dtlb_violation_write";
143 expname
= "fpu_exception";
146 expname
= "initial_page_write";
152 expname
= do_irq
? "interrupt" : "???";
155 qemu_log("exception 0x%03x [%s] raised\n",
156 irq_vector
, expname
);
157 log_cpu_state(cs
, 0);
162 env
->sgr
= env
->gregs
[15];
163 env
->sr
|= SR_BL
| SR_MD
| SR_RB
;
165 if (env
->flags
& (DELAY_SLOT
| DELAY_SLOT_CONDITIONAL
)) {
166 /* Branch instruction should be executed again before delay slot. */
168 /* Clear flags for exception/interrupt routine. */
169 env
->flags
&= ~(DELAY_SLOT
| DELAY_SLOT_CONDITIONAL
| DELAY_SLOT_TRUE
);
171 if (env
->flags
& DELAY_SLOT_CLEARME
)
175 env
->expevt
= cs
->exception_index
;
176 switch (cs
->exception_index
) {
181 env
->sr
|= 0xf << 4; /* IMASK */
182 env
->pc
= 0xa0000000;
186 env
->pc
= env
->vbr
+ 0x400;
189 env
->spc
+= 2; /* special case for TRAPA */
192 env
->pc
= env
->vbr
+ 0x100;
199 env
->intevt
= irq_vector
;
200 env
->pc
= env
->vbr
+ 0x600;
205 static void update_itlb_use(CPUSH4State
* env
, int itlbnb
)
207 uint8_t or_mask
= 0, and_mask
= (uint8_t) - 1;
226 env
->mmucr
&= (and_mask
<< 24) | 0x00ffffff;
227 env
->mmucr
|= (or_mask
<< 24);
230 static int itlb_replacement(CPUSH4State
* env
)
232 SuperHCPU
*cpu
= sh_env_get_cpu(env
);
234 if ((env
->mmucr
& 0xe0000000) == 0xe0000000) {
237 if ((env
->mmucr
& 0x98000000) == 0x18000000) {
240 if ((env
->mmucr
& 0x54000000) == 0x04000000) {
243 if ((env
->mmucr
& 0x2c000000) == 0x00000000) {
246 cpu_abort(CPU(cpu
), "Unhandled itlb_replacement");
249 /* Find the corresponding entry in the right TLB
250 Return entry, MMU_DTLB_MISS or MMU_DTLB_MULTIPLE
252 static int find_tlb_entry(CPUSH4State
* env
, target_ulong address
,
253 tlb_t
* entries
, uint8_t nbtlb
, int use_asid
)
255 int match
= MMU_DTLB_MISS
;
260 asid
= env
->pteh
& 0xff;
262 for (i
= 0; i
< nbtlb
; i
++) {
264 continue; /* Invalid entry */
265 if (!entries
[i
].sh
&& use_asid
&& entries
[i
].asid
!= asid
)
266 continue; /* Bad ASID */
267 start
= (entries
[i
].vpn
<< 10) & ~(entries
[i
].size
- 1);
268 end
= start
+ entries
[i
].size
- 1;
269 if (address
>= start
&& address
<= end
) { /* Match */
270 if (match
!= MMU_DTLB_MISS
)
271 return MMU_DTLB_MULTIPLE
; /* Multiple match */
278 static void increment_urc(CPUSH4State
* env
)
283 urb
= ((env
->mmucr
) >> 18) & 0x3f;
284 urc
= ((env
->mmucr
) >> 10) & 0x3f;
286 if ((urb
> 0 && urc
> urb
) || urc
> (UTLB_SIZE
- 1))
288 env
->mmucr
= (env
->mmucr
& 0xffff03ff) | (urc
<< 10);
291 /* Copy and utlb entry into itlb
294 static int copy_utlb_entry_itlb(CPUSH4State
*env
, int utlb
)
299 itlb
= itlb_replacement(env
);
300 ientry
= &env
->itlb
[itlb
];
302 tlb_flush_page(CPU(sh_env_get_cpu(env
)), ientry
->vpn
<< 10);
304 *ientry
= env
->utlb
[utlb
];
305 update_itlb_use(env
, itlb
);
310 Return entry, MMU_ITLB_MISS, MMU_ITLB_MULTIPLE or MMU_DTLB_MULTIPLE
312 static int find_itlb_entry(CPUSH4State
* env
, target_ulong address
,
317 e
= find_tlb_entry(env
, address
, env
->itlb
, ITLB_SIZE
, use_asid
);
318 if (e
== MMU_DTLB_MULTIPLE
) {
319 e
= MMU_ITLB_MULTIPLE
;
320 } else if (e
== MMU_DTLB_MISS
) {
323 update_itlb_use(env
, e
);
329 Return entry, MMU_DTLB_MISS, MMU_DTLB_MULTIPLE */
330 static int find_utlb_entry(CPUSH4State
* env
, target_ulong address
, int use_asid
)
332 /* per utlb access */
336 return find_tlb_entry(env
, address
, env
->utlb
, UTLB_SIZE
, use_asid
);
339 /* Match address against MMU
340 Return MMU_OK, MMU_DTLB_MISS_READ, MMU_DTLB_MISS_WRITE,
341 MMU_DTLB_INITIAL_WRITE, MMU_DTLB_VIOLATION_READ,
342 MMU_DTLB_VIOLATION_WRITE, MMU_ITLB_MISS,
343 MMU_ITLB_MULTIPLE, MMU_ITLB_VIOLATION,
344 MMU_IADDR_ERROR, MMU_DADDR_ERROR_READ, MMU_DADDR_ERROR_WRITE.
346 static int get_mmu_address(CPUSH4State
* env
, target_ulong
* physical
,
347 int *prot
, target_ulong address
,
348 int rw
, int access_type
)
351 tlb_t
*matching
= NULL
;
353 use_asid
= (env
->mmucr
& MMUCR_SV
) == 0 || (env
->sr
& SR_MD
) == 0;
356 n
= find_itlb_entry(env
, address
, use_asid
);
358 matching
= &env
->itlb
[n
];
359 if (!(env
->sr
& SR_MD
) && !(matching
->pr
& 2))
360 n
= MMU_ITLB_VIOLATION
;
364 n
= find_utlb_entry(env
, address
, use_asid
);
366 n
= copy_utlb_entry_itlb(env
, n
);
367 matching
= &env
->itlb
[n
];
368 if (!(env
->sr
& SR_MD
) && !(matching
->pr
& 2)) {
369 n
= MMU_ITLB_VIOLATION
;
371 *prot
= PAGE_READ
| PAGE_EXEC
;
372 if ((matching
->pr
& 1) && matching
->d
) {
376 } else if (n
== MMU_DTLB_MULTIPLE
) {
377 n
= MMU_ITLB_MULTIPLE
;
378 } else if (n
== MMU_DTLB_MISS
) {
383 n
= find_utlb_entry(env
, address
, use_asid
);
385 matching
= &env
->utlb
[n
];
386 if (!(env
->sr
& SR_MD
) && !(matching
->pr
& 2)) {
387 n
= (rw
== 1) ? MMU_DTLB_VIOLATION_WRITE
:
388 MMU_DTLB_VIOLATION_READ
;
389 } else if ((rw
== 1) && !(matching
->pr
& 1)) {
390 n
= MMU_DTLB_VIOLATION_WRITE
;
391 } else if ((rw
== 1) && !matching
->d
) {
392 n
= MMU_DTLB_INITIAL_WRITE
;
395 if ((matching
->pr
& 1) && matching
->d
) {
399 } else if (n
== MMU_DTLB_MISS
) {
400 n
= (rw
== 1) ? MMU_DTLB_MISS_WRITE
:
406 *physical
= ((matching
->ppn
<< 10) & ~(matching
->size
- 1)) |
407 (address
& (matching
->size
- 1));
412 static int get_physical_address(CPUSH4State
* env
, target_ulong
* physical
,
413 int *prot
, target_ulong address
,
414 int rw
, int access_type
)
416 /* P1, P2 and P4 areas do not use translation */
417 if ((address
>= 0x80000000 && address
< 0xc0000000) ||
418 address
>= 0xe0000000) {
419 if (!(env
->sr
& SR_MD
)
420 && (address
< 0xe0000000 || address
>= 0xe4000000)) {
421 /* Unauthorized access in user mode (only store queues are available) */
422 fprintf(stderr
, "Unauthorized access\n");
424 return MMU_DADDR_ERROR_READ
;
426 return MMU_DADDR_ERROR_WRITE
;
428 return MMU_IADDR_ERROR
;
430 if (address
>= 0x80000000 && address
< 0xc0000000) {
431 /* Mask upper 3 bits for P1 and P2 areas */
432 *physical
= address
& 0x1fffffff;
436 *prot
= PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
;
440 /* If MMU is disabled, return the corresponding physical page */
441 if (!(env
->mmucr
& MMUCR_AT
)) {
442 *physical
= address
& 0x1FFFFFFF;
443 *prot
= PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
;
447 /* We need to resort to the MMU */
448 return get_mmu_address(env
, physical
, prot
, address
, rw
, access_type
);
451 int superh_cpu_handle_mmu_fault(CPUState
*cs
, vaddr address
, int rw
,
454 SuperHCPU
*cpu
= SUPERH_CPU(cs
);
455 CPUSH4State
*env
= &cpu
->env
;
456 target_ulong physical
;
457 int prot
, ret
, access_type
;
459 access_type
= ACCESS_INT
;
461 get_physical_address(env
, &physical
, &prot
, address
, rw
,
466 if (ret
!= MMU_DTLB_MULTIPLE
&& ret
!= MMU_ITLB_MULTIPLE
) {
467 env
->pteh
= (env
->pteh
& PTEH_ASID_MASK
) |
468 (address
& PTEH_VPN_MASK
);
472 case MMU_DTLB_MISS_READ
:
473 cs
->exception_index
= 0x040;
475 case MMU_DTLB_MULTIPLE
:
476 case MMU_ITLB_MULTIPLE
:
477 cs
->exception_index
= 0x140;
479 case MMU_ITLB_VIOLATION
:
480 cs
->exception_index
= 0x0a0;
482 case MMU_DTLB_MISS_WRITE
:
483 cs
->exception_index
= 0x060;
485 case MMU_DTLB_INITIAL_WRITE
:
486 cs
->exception_index
= 0x080;
488 case MMU_DTLB_VIOLATION_READ
:
489 cs
->exception_index
= 0x0a0;
491 case MMU_DTLB_VIOLATION_WRITE
:
492 cs
->exception_index
= 0x0c0;
494 case MMU_IADDR_ERROR
:
495 case MMU_DADDR_ERROR_READ
:
496 cs
->exception_index
= 0x0e0;
498 case MMU_DADDR_ERROR_WRITE
:
499 cs
->exception_index
= 0x100;
502 cpu_abort(cs
, "Unhandled MMU fault");
507 address
&= TARGET_PAGE_MASK
;
508 physical
&= TARGET_PAGE_MASK
;
510 tlb_set_page(cs
, address
, physical
, prot
, mmu_idx
, TARGET_PAGE_SIZE
);
514 hwaddr
superh_cpu_get_phys_page_debug(CPUState
*cs
, vaddr addr
)
516 SuperHCPU
*cpu
= SUPERH_CPU(cs
);
517 target_ulong physical
;
520 get_physical_address(&cpu
->env
, &physical
, &prot
, addr
, 0, 0);
524 void cpu_load_tlb(CPUSH4State
* env
)
526 SuperHCPU
*cpu
= sh_env_get_cpu(env
);
527 int n
= cpu_mmucr_urc(env
->mmucr
);
528 tlb_t
* entry
= &env
->utlb
[n
];
531 /* Overwriting valid entry in utlb. */
532 target_ulong address
= entry
->vpn
<< 10;
533 tlb_flush_page(CPU(cpu
), address
);
536 /* Take values into cpu status from registers. */
537 entry
->asid
= (uint8_t)cpu_pteh_asid(env
->pteh
);
538 entry
->vpn
= cpu_pteh_vpn(env
->pteh
);
539 entry
->v
= (uint8_t)cpu_ptel_v(env
->ptel
);
540 entry
->ppn
= cpu_ptel_ppn(env
->ptel
);
541 entry
->sz
= (uint8_t)cpu_ptel_sz(env
->ptel
);
544 entry
->size
= 1024; /* 1K */
547 entry
->size
= 1024 * 4; /* 4K */
550 entry
->size
= 1024 * 64; /* 64K */
553 entry
->size
= 1024 * 1024; /* 1M */
556 cpu_abort(CPU(cpu
), "Unhandled load_tlb");
559 entry
->sh
= (uint8_t)cpu_ptel_sh(env
->ptel
);
560 entry
->c
= (uint8_t)cpu_ptel_c(env
->ptel
);
561 entry
->pr
= (uint8_t)cpu_ptel_pr(env
->ptel
);
562 entry
->d
= (uint8_t)cpu_ptel_d(env
->ptel
);
563 entry
->wt
= (uint8_t)cpu_ptel_wt(env
->ptel
);
564 entry
->sa
= (uint8_t)cpu_ptea_sa(env
->ptea
);
565 entry
->tc
= (uint8_t)cpu_ptea_tc(env
->ptea
);
568 void cpu_sh4_invalidate_tlb(CPUSH4State
*s
)
573 for (i
= 0; i
< UTLB_SIZE
; i
++) {
574 tlb_t
* entry
= &s
->utlb
[i
];
578 for (i
= 0; i
< ITLB_SIZE
; i
++) {
579 tlb_t
* entry
= &s
->itlb
[i
];
583 tlb_flush(CPU(sh_env_get_cpu(s
)), 1);
586 uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State
*s
,
589 int index
= (addr
& 0x00000300) >> 8;
590 tlb_t
* entry
= &s
->itlb
[index
];
592 return (entry
->vpn
<< 10) |
597 void cpu_sh4_write_mmaped_itlb_addr(CPUSH4State
*s
, hwaddr addr
,
600 uint32_t vpn
= (mem_value
& 0xfffffc00) >> 10;
601 uint8_t v
= (uint8_t)((mem_value
& 0x00000100) >> 8);
602 uint8_t asid
= (uint8_t)(mem_value
& 0x000000ff);
604 int index
= (addr
& 0x00000300) >> 8;
605 tlb_t
* entry
= &s
->itlb
[index
];
607 /* Overwriting valid entry in itlb. */
608 target_ulong address
= entry
->vpn
<< 10;
609 tlb_flush_page(CPU(sh_env_get_cpu(s
)), address
);
616 uint32_t cpu_sh4_read_mmaped_itlb_data(CPUSH4State
*s
,
619 int array
= (addr
& 0x00800000) >> 23;
620 int index
= (addr
& 0x00000300) >> 8;
621 tlb_t
* entry
= &s
->itlb
[index
];
624 /* ITLB Data Array 1 */
625 return (entry
->ppn
<< 10) |
628 ((entry
->sz
& 1) << 6) |
629 ((entry
->sz
& 2) << 4) |
633 /* ITLB Data Array 2 */
634 return (entry
->tc
<< 1) |
639 void cpu_sh4_write_mmaped_itlb_data(CPUSH4State
*s
, hwaddr addr
,
642 int array
= (addr
& 0x00800000) >> 23;
643 int index
= (addr
& 0x00000300) >> 8;
644 tlb_t
* entry
= &s
->itlb
[index
];
647 /* ITLB Data Array 1 */
649 /* Overwriting valid entry in utlb. */
650 target_ulong address
= entry
->vpn
<< 10;
651 tlb_flush_page(CPU(sh_env_get_cpu(s
)), address
);
653 entry
->ppn
= (mem_value
& 0x1ffffc00) >> 10;
654 entry
->v
= (mem_value
& 0x00000100) >> 8;
655 entry
->sz
= (mem_value
& 0x00000080) >> 6 |
656 (mem_value
& 0x00000010) >> 4;
657 entry
->pr
= (mem_value
& 0x00000040) >> 5;
658 entry
->c
= (mem_value
& 0x00000008) >> 3;
659 entry
->sh
= (mem_value
& 0x00000002) >> 1;
661 /* ITLB Data Array 2 */
662 entry
->tc
= (mem_value
& 0x00000008) >> 3;
663 entry
->sa
= (mem_value
& 0x00000007);
667 uint32_t cpu_sh4_read_mmaped_utlb_addr(CPUSH4State
*s
,
670 int index
= (addr
& 0x00003f00) >> 8;
671 tlb_t
* entry
= &s
->utlb
[index
];
673 increment_urc(s
); /* per utlb access */
675 return (entry
->vpn
<< 10) |
680 void cpu_sh4_write_mmaped_utlb_addr(CPUSH4State
*s
, hwaddr addr
,
683 int associate
= addr
& 0x0000080;
684 uint32_t vpn
= (mem_value
& 0xfffffc00) >> 10;
685 uint8_t d
= (uint8_t)((mem_value
& 0x00000200) >> 9);
686 uint8_t v
= (uint8_t)((mem_value
& 0x00000100) >> 8);
687 uint8_t asid
= (uint8_t)(mem_value
& 0x000000ff);
688 int use_asid
= (s
->mmucr
& MMUCR_SV
) == 0 || (s
->sr
& SR_MD
) == 0;
692 tlb_t
* utlb_match_entry
= NULL
;
693 int needs_tlb_flush
= 0;
696 for (i
= 0; i
< UTLB_SIZE
; i
++) {
697 tlb_t
* entry
= &s
->utlb
[i
];
701 if (entry
->vpn
== vpn
702 && (!use_asid
|| entry
->asid
== asid
|| entry
->sh
)) {
703 if (utlb_match_entry
) {
704 CPUState
*cs
= CPU(sh_env_get_cpu(s
));
706 /* Multiple TLB Exception */
707 cs
->exception_index
= 0x140;
715 utlb_match_entry
= entry
;
717 increment_urc(s
); /* per utlb access */
721 for (i
= 0; i
< ITLB_SIZE
; i
++) {
722 tlb_t
* entry
= &s
->itlb
[i
];
723 if (entry
->vpn
== vpn
724 && (!use_asid
|| entry
->asid
== asid
|| entry
->sh
)) {
727 if (utlb_match_entry
)
728 *entry
= *utlb_match_entry
;
735 if (needs_tlb_flush
) {
736 tlb_flush_page(CPU(sh_env_get_cpu(s
)), vpn
<< 10);
740 int index
= (addr
& 0x00003f00) >> 8;
741 tlb_t
* entry
= &s
->utlb
[index
];
743 CPUState
*cs
= CPU(sh_env_get_cpu(s
));
745 /* Overwriting valid entry in utlb. */
746 target_ulong address
= entry
->vpn
<< 10;
747 tlb_flush_page(cs
, address
);
757 uint32_t cpu_sh4_read_mmaped_utlb_data(CPUSH4State
*s
,
760 int array
= (addr
& 0x00800000) >> 23;
761 int index
= (addr
& 0x00003f00) >> 8;
762 tlb_t
* entry
= &s
->utlb
[index
];
764 increment_urc(s
); /* per utlb access */
767 /* ITLB Data Array 1 */
768 return (entry
->ppn
<< 10) |
771 ((entry
->sz
& 1) << 6) |
772 ((entry
->sz
& 2) << 4) |
778 /* ITLB Data Array 2 */
779 return (entry
->tc
<< 1) |
784 void cpu_sh4_write_mmaped_utlb_data(CPUSH4State
*s
, hwaddr addr
,
787 int array
= (addr
& 0x00800000) >> 23;
788 int index
= (addr
& 0x00003f00) >> 8;
789 tlb_t
* entry
= &s
->utlb
[index
];
791 increment_urc(s
); /* per utlb access */
794 /* UTLB Data Array 1 */
796 /* Overwriting valid entry in utlb. */
797 target_ulong address
= entry
->vpn
<< 10;
798 tlb_flush_page(CPU(sh_env_get_cpu(s
)), address
);
800 entry
->ppn
= (mem_value
& 0x1ffffc00) >> 10;
801 entry
->v
= (mem_value
& 0x00000100) >> 8;
802 entry
->sz
= (mem_value
& 0x00000080) >> 6 |
803 (mem_value
& 0x00000010) >> 4;
804 entry
->pr
= (mem_value
& 0x00000060) >> 5;
805 entry
->c
= (mem_value
& 0x00000008) >> 3;
806 entry
->d
= (mem_value
& 0x00000004) >> 2;
807 entry
->sh
= (mem_value
& 0x00000002) >> 1;
808 entry
->wt
= (mem_value
& 0x00000001);
810 /* UTLB Data Array 2 */
811 entry
->tc
= (mem_value
& 0x00000008) >> 3;
812 entry
->sa
= (mem_value
& 0x00000007);
816 int cpu_sh4_is_cached(CPUSH4State
* env
, target_ulong addr
)
819 int use_asid
= (env
->mmucr
& MMUCR_SV
) == 0 || (env
->sr
& SR_MD
) == 0;
822 if (env
->sr
& SR_MD
) {
823 /* For previledged mode, P2 and P4 area is not cachable. */
824 if ((0xA0000000 <= addr
&& addr
< 0xC0000000) || 0xE0000000 <= addr
)
827 /* For user mode, only U0 area is cachable. */
828 if (0x80000000 <= addr
)
833 * TODO : Evaluate CCR and check if the cache is on or off.
834 * Now CCR is not in CPUSH4State, but in SH7750State.
835 * When you move the ccr into CPUSH4State, the code will be
839 /* check if operand cache is enabled or not. */
844 /* if MMU is off, no check for TLB. */
845 if (env
->mmucr
& MMUCR_AT
)
849 n
= find_tlb_entry(env
, addr
, env
->itlb
, ITLB_SIZE
, use_asid
);
851 return env
->itlb
[n
].c
;
853 n
= find_tlb_entry(env
, addr
, env
->utlb
, UTLB_SIZE
, use_asid
);
855 return env
->utlb
[n
].c
;
862 bool superh_cpu_exec_interrupt(CPUState
*cs
, int interrupt_request
)
864 if (interrupt_request
& CPU_INTERRUPT_HARD
) {
865 superh_cpu_do_interrupt(cs
);