2 * Copyright (c) 2011, Max Filippov, Open Source and Linux Lab.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the Open Source and Linux Lab nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include "qemu/osdep.h"
30 #include "exec/exec-all.h"
31 #include "exec/gdbstub.h"
32 #include "qemu/host-utils.h"
33 #if !defined(CONFIG_USER_ONLY)
34 #include "hw/loader.h"
37 static struct XtensaConfigList
*xtensa_cores
;
39 static void xtensa_core_class_init(ObjectClass
*oc
, void *data
)
41 CPUClass
*cc
= CPU_CLASS(oc
);
42 XtensaCPUClass
*xcc
= XTENSA_CPU_CLASS(oc
);
43 const XtensaConfig
*config
= data
;
47 /* Use num_core_regs to see only non-privileged registers in an unmodified
48 * gdb. Use num_regs to see all registers. gdb modification is required
49 * for that: reset bit 0 in the 'flags' field of the registers definitions
50 * in the gdb/xtensa-config.c inside gdb source tree or inside gdb overlay.
52 cc
->gdb_num_core_regs
= config
->gdb_regmap
.num_regs
;
55 static void init_libisa(XtensaConfig
*config
)
60 config
->isa
= xtensa_isa_init(config
->isa_internal
, NULL
, NULL
);
61 assert(xtensa_isa_maxlength(config
->isa
) <= MAX_INSN_LENGTH
);
62 opcodes
= xtensa_isa_num_opcodes(config
->isa
);
63 config
->opcode_ops
= g_new(XtensaOpcodeOps
*, opcodes
);
65 for (i
= 0; i
< opcodes
; ++i
) {
66 const char *opc_name
= xtensa_opcode_name(config
->isa
, i
);
67 XtensaOpcodeOps
*ops
= NULL
;
69 assert(xtensa_opcode_num_operands(config
->isa
, i
) <= MAX_OPCODE_ARGS
);
70 if (!config
->opcode_translators
) {
71 ops
= xtensa_find_opcode_ops(&xtensa_core_opcodes
, opc_name
);
73 for (j
= 0; !ops
&& config
->opcode_translators
[j
]; ++j
) {
74 ops
= xtensa_find_opcode_ops(config
->opcode_translators
[j
],
81 "opcode translator not found for %s's opcode '%s'\n",
82 config
->name
, opc_name
);
85 config
->opcode_ops
[i
] = ops
;
89 void xtensa_finalize_config(XtensaConfig
*config
)
93 if (config
->isa_internal
) {
96 if (config
->gdb_regmap
.num_regs
) {
100 for (i
= 0; config
->gdb_regmap
.reg
[i
].targno
>= 0; ++i
) {
101 n
+= (config
->gdb_regmap
.reg
[i
].type
!= 6);
103 config
->gdb_regmap
.num_regs
= n
;
106 void xtensa_register_core(XtensaConfigList
*node
)
109 .parent
= TYPE_XTENSA_CPU
,
110 .class_init
= xtensa_core_class_init
,
111 .class_data
= (void *)node
->config
,
114 node
->next
= xtensa_cores
;
116 type
.name
= g_strdup_printf(XTENSA_CPU_TYPE_NAME("%s"), node
->config
->name
);
117 type_register(&type
);
118 g_free((gpointer
)type
.name
);
121 static uint32_t check_hw_breakpoints(CPUXtensaState
*env
)
125 for (i
= 0; i
< env
->config
->ndbreak
; ++i
) {
126 if (env
->cpu_watchpoint
[i
] &&
127 env
->cpu_watchpoint
[i
]->flags
& BP_WATCHPOINT_HIT
) {
128 return DEBUGCAUSE_DB
| (i
<< DEBUGCAUSE_DBNUM_SHIFT
);
134 void xtensa_breakpoint_handler(CPUState
*cs
)
136 XtensaCPU
*cpu
= XTENSA_CPU(cs
);
137 CPUXtensaState
*env
= &cpu
->env
;
139 if (cs
->watchpoint_hit
) {
140 if (cs
->watchpoint_hit
->flags
& BP_CPU
) {
143 cs
->watchpoint_hit
= NULL
;
144 cause
= check_hw_breakpoints(env
);
146 debug_exception_env(env
, cause
);
148 cpu_loop_exit_noexc(cs
);
153 void xtensa_cpu_list(FILE *f
, fprintf_function cpu_fprintf
)
155 XtensaConfigList
*core
= xtensa_cores
;
156 cpu_fprintf(f
, "Available CPUs:\n");
157 for (; core
; core
= core
->next
) {
158 cpu_fprintf(f
, " %s\n", core
->config
->name
);
162 hwaddr
xtensa_cpu_get_phys_page_debug(CPUState
*cs
, vaddr addr
)
164 XtensaCPU
*cpu
= XTENSA_CPU(cs
);
169 if (xtensa_get_physical_addr(&cpu
->env
, false, addr
, 0, 0,
170 &paddr
, &page_size
, &access
) == 0) {
173 if (xtensa_get_physical_addr(&cpu
->env
, false, addr
, 2, 0,
174 &paddr
, &page_size
, &access
) == 0) {
180 static uint32_t relocated_vector(CPUXtensaState
*env
, uint32_t vector
)
182 if (xtensa_option_enabled(env
->config
,
183 XTENSA_OPTION_RELOCATABLE_VECTOR
)) {
184 return vector
- env
->config
->vecbase
+ env
->sregs
[VECBASE
];
191 * Handle penging IRQ.
192 * For the high priority interrupt jump to the corresponding interrupt vector.
193 * For the level-1 interrupt convert it to either user, kernel or double
194 * exception with the 'level-1 interrupt' exception cause.
196 static void handle_interrupt(CPUXtensaState
*env
)
198 int level
= env
->pending_irq_level
;
200 if (level
> xtensa_get_cintlevel(env
) &&
201 level
<= env
->config
->nlevel
&&
202 (env
->config
->level_mask
[level
] &
204 env
->sregs
[INTENABLE
])) {
205 CPUState
*cs
= CPU(xtensa_env_get_cpu(env
));
208 env
->sregs
[EPC1
+ level
- 1] = env
->pc
;
209 env
->sregs
[EPS2
+ level
- 2] = env
->sregs
[PS
];
211 (env
->sregs
[PS
] & ~PS_INTLEVEL
) | level
| PS_EXCM
;
212 env
->pc
= relocated_vector(env
,
213 env
->config
->interrupt_vector
[level
]);
215 env
->sregs
[EXCCAUSE
] = LEVEL1_INTERRUPT_CAUSE
;
217 if (env
->sregs
[PS
] & PS_EXCM
) {
218 if (env
->config
->ndepc
) {
219 env
->sregs
[DEPC
] = env
->pc
;
221 env
->sregs
[EPC1
] = env
->pc
;
223 cs
->exception_index
= EXC_DOUBLE
;
225 env
->sregs
[EPC1
] = env
->pc
;
226 cs
->exception_index
=
227 (env
->sregs
[PS
] & PS_UM
) ? EXC_USER
: EXC_KERNEL
;
229 env
->sregs
[PS
] |= PS_EXCM
;
231 env
->exception_taken
= 1;
235 /* Called from cpu_handle_interrupt with BQL held */
236 void xtensa_cpu_do_interrupt(CPUState
*cs
)
238 XtensaCPU
*cpu
= XTENSA_CPU(cs
);
239 CPUXtensaState
*env
= &cpu
->env
;
241 if (cs
->exception_index
== EXC_IRQ
) {
242 qemu_log_mask(CPU_LOG_INT
,
243 "%s(EXC_IRQ) level = %d, cintlevel = %d, "
244 "pc = %08x, a0 = %08x, ps = %08x, "
245 "intset = %08x, intenable = %08x, "
247 __func__
, env
->pending_irq_level
, xtensa_get_cintlevel(env
),
248 env
->pc
, env
->regs
[0], env
->sregs
[PS
],
249 env
->sregs
[INTSET
], env
->sregs
[INTENABLE
],
251 handle_interrupt(env
);
254 switch (cs
->exception_index
) {
255 case EXC_WINDOW_OVERFLOW4
:
256 case EXC_WINDOW_UNDERFLOW4
:
257 case EXC_WINDOW_OVERFLOW8
:
258 case EXC_WINDOW_UNDERFLOW8
:
259 case EXC_WINDOW_OVERFLOW12
:
260 case EXC_WINDOW_UNDERFLOW12
:
265 qemu_log_mask(CPU_LOG_INT
, "%s(%d) "
266 "pc = %08x, a0 = %08x, ps = %08x, ccount = %08x\n",
267 __func__
, cs
->exception_index
,
268 env
->pc
, env
->regs
[0], env
->sregs
[PS
], env
->sregs
[CCOUNT
]);
269 if (env
->config
->exception_vector
[cs
->exception_index
]) {
270 env
->pc
= relocated_vector(env
,
271 env
->config
->exception_vector
[cs
->exception_index
]);
272 env
->exception_taken
= 1;
274 qemu_log_mask(CPU_LOG_INT
, "%s(pc = %08x) bad exception_index: %d\n",
275 __func__
, env
->pc
, cs
->exception_index
);
283 qemu_log("%s(pc = %08x) unknown exception_index: %d\n",
284 __func__
, env
->pc
, cs
->exception_index
);
287 check_interrupts(env
);
290 bool xtensa_cpu_exec_interrupt(CPUState
*cs
, int interrupt_request
)
292 if (interrupt_request
& CPU_INTERRUPT_HARD
) {
293 cs
->exception_index
= EXC_IRQ
;
294 xtensa_cpu_do_interrupt(cs
);
300 static void reset_tlb_mmu_all_ways(CPUXtensaState
*env
,
301 const xtensa_tlb
*tlb
, xtensa_tlb_entry entry
[][MAX_TLB_WAY_SIZE
])
305 for (wi
= 0; wi
< tlb
->nways
; ++wi
) {
306 for (ei
= 0; ei
< tlb
->way_size
[wi
]; ++ei
) {
307 entry
[wi
][ei
].asid
= 0;
308 entry
[wi
][ei
].variable
= true;
313 static void reset_tlb_mmu_ways56(CPUXtensaState
*env
,
314 const xtensa_tlb
*tlb
, xtensa_tlb_entry entry
[][MAX_TLB_WAY_SIZE
])
316 if (!tlb
->varway56
) {
317 static const xtensa_tlb_entry way5
[] = {
332 static const xtensa_tlb_entry way6
[] = {
347 memcpy(entry
[5], way5
, sizeof(way5
));
348 memcpy(entry
[6], way6
, sizeof(way6
));
351 for (ei
= 0; ei
< 8; ++ei
) {
352 entry
[6][ei
].vaddr
= ei
<< 29;
353 entry
[6][ei
].paddr
= ei
<< 29;
354 entry
[6][ei
].asid
= 1;
355 entry
[6][ei
].attr
= 3;
360 static void reset_tlb_region_way0(CPUXtensaState
*env
,
361 xtensa_tlb_entry entry
[][MAX_TLB_WAY_SIZE
])
365 for (ei
= 0; ei
< 8; ++ei
) {
366 entry
[0][ei
].vaddr
= ei
<< 29;
367 entry
[0][ei
].paddr
= ei
<< 29;
368 entry
[0][ei
].asid
= 1;
369 entry
[0][ei
].attr
= 2;
370 entry
[0][ei
].variable
= true;
374 void reset_mmu(CPUXtensaState
*env
)
376 if (xtensa_option_enabled(env
->config
, XTENSA_OPTION_MMU
)) {
377 env
->sregs
[RASID
] = 0x04030201;
378 env
->sregs
[ITLBCFG
] = 0;
379 env
->sregs
[DTLBCFG
] = 0;
380 env
->autorefill_idx
= 0;
381 reset_tlb_mmu_all_ways(env
, &env
->config
->itlb
, env
->itlb
);
382 reset_tlb_mmu_all_ways(env
, &env
->config
->dtlb
, env
->dtlb
);
383 reset_tlb_mmu_ways56(env
, &env
->config
->itlb
, env
->itlb
);
384 reset_tlb_mmu_ways56(env
, &env
->config
->dtlb
, env
->dtlb
);
386 reset_tlb_region_way0(env
, env
->itlb
);
387 reset_tlb_region_way0(env
, env
->dtlb
);
391 static unsigned get_ring(const CPUXtensaState
*env
, uint8_t asid
)
394 for (i
= 0; i
< 4; ++i
) {
395 if (((env
->sregs
[RASID
] >> i
* 8) & 0xff) == asid
) {
403 * Lookup xtensa TLB for the given virtual address.
406 * \param pwi: [out] way index
407 * \param pei: [out] entry index
408 * \param pring: [out] access ring
409 * \return 0 if ok, exception cause code otherwise
411 int xtensa_tlb_lookup(const CPUXtensaState
*env
, uint32_t addr
, bool dtlb
,
412 uint32_t *pwi
, uint32_t *pei
, uint8_t *pring
)
414 const xtensa_tlb
*tlb
= dtlb
?
415 &env
->config
->dtlb
: &env
->config
->itlb
;
416 const xtensa_tlb_entry (*entry
)[MAX_TLB_WAY_SIZE
] = dtlb
?
417 env
->dtlb
: env
->itlb
;
422 for (wi
= 0; wi
< tlb
->nways
; ++wi
) {
425 split_tlb_entry_spec_way(env
, addr
, dtlb
, &vpn
, wi
, &ei
);
426 if (entry
[wi
][ei
].vaddr
== vpn
&& entry
[wi
][ei
].asid
) {
427 unsigned ring
= get_ring(env
, entry
[wi
][ei
].asid
);
431 LOAD_STORE_TLB_MULTI_HIT_CAUSE
:
432 INST_TLB_MULTI_HIT_CAUSE
;
441 (dtlb
? LOAD_STORE_TLB_MISS_CAUSE
: INST_TLB_MISS_CAUSE
);
445 * Convert MMU ATTR to PAGE_{READ,WRITE,EXEC} mask.
448 static unsigned mmu_attr_to_access(uint32_t attr
)
458 access
|= PAGE_WRITE
;
461 switch (attr
& 0xc) {
463 access
|= PAGE_CACHE_BYPASS
;
467 access
|= PAGE_CACHE_WB
;
471 access
|= PAGE_CACHE_WT
;
474 } else if (attr
== 13) {
475 access
|= PAGE_READ
| PAGE_WRITE
| PAGE_CACHE_ISOLATE
;
481 * Convert region protection ATTR to PAGE_{READ,WRITE,EXEC} mask.
484 static unsigned region_attr_to_access(uint32_t attr
)
486 static const unsigned access
[16] = {
487 [0] = PAGE_READ
| PAGE_WRITE
| PAGE_CACHE_WT
,
488 [1] = PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
| PAGE_CACHE_WT
,
489 [2] = PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
| PAGE_CACHE_BYPASS
,
490 [3] = PAGE_EXEC
| PAGE_CACHE_WB
,
491 [4] = PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
| PAGE_CACHE_WB
,
492 [5] = PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
| PAGE_CACHE_WB
,
493 [14] = PAGE_READ
| PAGE_WRITE
| PAGE_CACHE_ISOLATE
,
496 return access
[attr
& 0xf];
500 * Convert cacheattr to PAGE_{READ,WRITE,EXEC} mask.
501 * See ISA, A.2.14 The Cache Attribute Register
503 static unsigned cacheattr_attr_to_access(uint32_t attr
)
505 static const unsigned access
[16] = {
506 [0] = PAGE_READ
| PAGE_WRITE
| PAGE_CACHE_WT
,
507 [1] = PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
| PAGE_CACHE_WT
,
508 [2] = PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
| PAGE_CACHE_BYPASS
,
509 [3] = PAGE_EXEC
| PAGE_CACHE_WB
,
510 [4] = PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
| PAGE_CACHE_WB
,
511 [14] = PAGE_READ
| PAGE_WRITE
| PAGE_CACHE_ISOLATE
,
514 return access
[attr
& 0xf];
517 static bool is_access_granted(unsigned access
, int is_write
)
521 return access
& PAGE_READ
;
524 return access
& PAGE_WRITE
;
527 return access
& PAGE_EXEC
;
534 static int get_pte(CPUXtensaState
*env
, uint32_t vaddr
, uint32_t *pte
);
536 static int get_physical_addr_mmu(CPUXtensaState
*env
, bool update_tlb
,
537 uint32_t vaddr
, int is_write
, int mmu_idx
,
538 uint32_t *paddr
, uint32_t *page_size
, unsigned *access
,
541 bool dtlb
= is_write
!= 2;
547 const xtensa_tlb_entry
*entry
= NULL
;
548 xtensa_tlb_entry tmp_entry
;
549 int ret
= xtensa_tlb_lookup(env
, vaddr
, dtlb
, &wi
, &ei
, &ring
);
551 if ((ret
== INST_TLB_MISS_CAUSE
|| ret
== LOAD_STORE_TLB_MISS_CAUSE
) &&
552 may_lookup_pt
&& get_pte(env
, vaddr
, &pte
) == 0) {
553 ring
= (pte
>> 4) & 0x3;
555 split_tlb_entry_spec_way(env
, vaddr
, dtlb
, &vpn
, wi
, &ei
);
558 wi
= ++env
->autorefill_idx
& 0x3;
559 xtensa_tlb_set_entry(env
, dtlb
, wi
, ei
, vpn
, pte
);
560 env
->sregs
[EXCVADDR
] = vaddr
;
561 qemu_log_mask(CPU_LOG_MMU
, "%s: autorefill(%08x): %08x -> %08x\n",
562 __func__
, vaddr
, vpn
, pte
);
564 xtensa_tlb_set_entry_mmu(env
, &tmp_entry
, dtlb
, wi
, ei
, vpn
, pte
);
574 entry
= xtensa_tlb_get_entry(env
, dtlb
, wi
, ei
);
577 if (ring
< mmu_idx
) {
579 LOAD_STORE_PRIVILEGE_CAUSE
:
580 INST_FETCH_PRIVILEGE_CAUSE
;
583 *access
= mmu_attr_to_access(entry
->attr
) &
584 ~(dtlb
? PAGE_EXEC
: PAGE_READ
| PAGE_WRITE
);
585 if (!is_access_granted(*access
, is_write
)) {
588 STORE_PROHIBITED_CAUSE
:
589 LOAD_PROHIBITED_CAUSE
) :
590 INST_FETCH_PROHIBITED_CAUSE
;
593 *paddr
= entry
->paddr
| (vaddr
& ~xtensa_tlb_get_addr_mask(env
, dtlb
, wi
));
594 *page_size
= ~xtensa_tlb_get_addr_mask(env
, dtlb
, wi
) + 1;
599 static int get_pte(CPUXtensaState
*env
, uint32_t vaddr
, uint32_t *pte
)
601 CPUState
*cs
= CPU(xtensa_env_get_cpu(env
));
606 (env
->sregs
[PTEVADDR
] | (vaddr
>> 10)) & 0xfffffffc;
607 int ret
= get_physical_addr_mmu(env
, false, pt_vaddr
, 0, 0,
608 &paddr
, &page_size
, &access
, false);
610 qemu_log_mask(CPU_LOG_MMU
, "%s: trying autorefill(%08x) -> %08x\n",
611 __func__
, vaddr
, ret
? ~0 : paddr
);
614 *pte
= ldl_phys(cs
->as
, paddr
);
619 static int get_physical_addr_region(CPUXtensaState
*env
,
620 uint32_t vaddr
, int is_write
, int mmu_idx
,
621 uint32_t *paddr
, uint32_t *page_size
, unsigned *access
)
623 bool dtlb
= is_write
!= 2;
625 uint32_t ei
= (vaddr
>> 29) & 0x7;
626 const xtensa_tlb_entry
*entry
=
627 xtensa_tlb_get_entry(env
, dtlb
, wi
, ei
);
629 *access
= region_attr_to_access(entry
->attr
);
630 if (!is_access_granted(*access
, is_write
)) {
633 STORE_PROHIBITED_CAUSE
:
634 LOAD_PROHIBITED_CAUSE
) :
635 INST_FETCH_PROHIBITED_CAUSE
;
638 *paddr
= entry
->paddr
| (vaddr
& ~REGION_PAGE_MASK
);
639 *page_size
= ~REGION_PAGE_MASK
+ 1;
645 * Convert virtual address to physical addr.
646 * MMU may issue pagewalk and change xtensa autorefill TLB way entry.
648 * \return 0 if ok, exception cause code otherwise
650 int xtensa_get_physical_addr(CPUXtensaState
*env
, bool update_tlb
,
651 uint32_t vaddr
, int is_write
, int mmu_idx
,
652 uint32_t *paddr
, uint32_t *page_size
, unsigned *access
)
654 if (xtensa_option_enabled(env
->config
, XTENSA_OPTION_MMU
)) {
655 return get_physical_addr_mmu(env
, update_tlb
,
656 vaddr
, is_write
, mmu_idx
, paddr
, page_size
, access
, true);
657 } else if (xtensa_option_bits_enabled(env
->config
,
658 XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION
) |
659 XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION
))) {
660 return get_physical_addr_region(env
, vaddr
, is_write
, mmu_idx
,
661 paddr
, page_size
, access
);
664 *page_size
= TARGET_PAGE_SIZE
;
665 *access
= cacheattr_attr_to_access(
666 env
->sregs
[CACHEATTR
] >> ((vaddr
& 0xe0000000) >> 27));
671 static void dump_tlb(FILE *f
, fprintf_function cpu_fprintf
,
672 CPUXtensaState
*env
, bool dtlb
)
675 const xtensa_tlb
*conf
=
676 dtlb
? &env
->config
->dtlb
: &env
->config
->itlb
;
677 unsigned (*attr_to_access
)(uint32_t) =
678 xtensa_option_enabled(env
->config
, XTENSA_OPTION_MMU
) ?
679 mmu_attr_to_access
: region_attr_to_access
;
681 for (wi
= 0; wi
< conf
->nways
; ++wi
) {
682 uint32_t sz
= ~xtensa_tlb_get_addr_mask(env
, dtlb
, wi
) + 1;
684 bool print_header
= true;
686 if (sz
>= 0x100000) {
694 for (ei
= 0; ei
< conf
->way_size
[wi
]; ++ei
) {
695 const xtensa_tlb_entry
*entry
=
696 xtensa_tlb_get_entry(env
, dtlb
, wi
, ei
);
699 static const char * const cache_text
[8] = {
700 [PAGE_CACHE_BYPASS
>> PAGE_CACHE_SHIFT
] = "Bypass",
701 [PAGE_CACHE_WT
>> PAGE_CACHE_SHIFT
] = "WT",
702 [PAGE_CACHE_WB
>> PAGE_CACHE_SHIFT
] = "WB",
703 [PAGE_CACHE_ISOLATE
>> PAGE_CACHE_SHIFT
] = "Isolate",
705 unsigned access
= attr_to_access(entry
->attr
);
706 unsigned cache_idx
= (access
& PAGE_CACHE_MASK
) >>
710 print_header
= false;
711 cpu_fprintf(f
, "Way %u (%d %s)\n", wi
, sz
, sz_text
);
713 "\tVaddr Paddr ASID Attr RWX Cache\n"
714 "\t---------- ---------- ---- ---- --- -------\n");
717 "\t0x%08x 0x%08x 0x%02x 0x%02x %c%c%c %-7s\n",
722 (access
& PAGE_READ
) ? 'R' : '-',
723 (access
& PAGE_WRITE
) ? 'W' : '-',
724 (access
& PAGE_EXEC
) ? 'X' : '-',
725 cache_text
[cache_idx
] ? cache_text
[cache_idx
] :
732 void dump_mmu(FILE *f
, fprintf_function cpu_fprintf
, CPUXtensaState
*env
)
734 if (xtensa_option_bits_enabled(env
->config
,
735 XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION
) |
736 XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION
) |
737 XTENSA_OPTION_BIT(XTENSA_OPTION_MMU
))) {
739 cpu_fprintf(f
, "ITLB:\n");
740 dump_tlb(f
, cpu_fprintf
, env
, false);
741 cpu_fprintf(f
, "\nDTLB:\n");
742 dump_tlb(f
, cpu_fprintf
, env
, true);
744 cpu_fprintf(f
, "No TLB for this CPU core\n");
748 void xtensa_runstall(CPUXtensaState
*env
, bool runstall
)
750 CPUState
*cpu
= CPU(xtensa_env_get_cpu(env
));
752 env
->runstall
= runstall
;
753 cpu
->halted
= runstall
;
755 cpu_interrupt(cpu
, CPU_INTERRUPT_HALT
);
757 cpu_reset_interrupt(cpu
, CPU_INTERRUPT_HALT
);