[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 47/53] target/sh4: convert to use format_tlb callback
From: |
Daniel P . Berrangé |
Subject: |
[PATCH v2 47/53] target/sh4: convert to use format_tlb callback |
Date: |
Tue, 14 Sep 2021 15:20:36 +0100 |
Change the "info tlb" implementation to use the format_tlb callback.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
target/sh4/cpu.c | 3 +++
target/sh4/cpu.h | 1 +
target/sh4/monitor.c | 48 +++++++++++++++++++++++++++-----------------
3 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
index 0ac881d6af..0e49755b2a 100644
--- a/target/sh4/cpu.c
+++ b/target/sh4/cpu.c
@@ -260,6 +260,9 @@ static void superh_cpu_class_init(ObjectClass *oc, void
*data)
cc->class_by_name = superh_cpu_class_by_name;
cc->has_work = superh_cpu_has_work;
cc->format_state = superh_cpu_format_state;
+#ifndef CONFIG_USER_ONLY
+ cc->format_tlb = superh_cpu_format_tlb;
+#endif
cc->set_pc = superh_cpu_set_pc;
cc->gdb_read_register = superh_cpu_gdb_read_register;
cc->gdb_write_register = superh_cpu_gdb_write_register;
diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
index 6940ca417a..7c139f561c 100644
--- a/target/sh4/cpu.h
+++ b/target/sh4/cpu.h
@@ -207,6 +207,7 @@ struct SuperHCPU {
void superh_cpu_do_interrupt(CPUState *cpu);
bool superh_cpu_exec_interrupt(CPUState *cpu, int int_req);
void superh_cpu_format_state(CPUState *cpu, GString *buf, int flags);
+void superh_cpu_format_tlb(CPUState *cpu, GString *buf);
hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
int superh_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
int superh_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
diff --git a/target/sh4/monitor.c b/target/sh4/monitor.c
index 2da6a5426e..5ccb95af93 100644
--- a/target/sh4/monitor.c
+++ b/target/sh4/monitor.c
@@ -27,32 +27,44 @@
#include "monitor/hmp-target.h"
#include "monitor/hmp.h"
-static void print_tlb(Monitor *mon, int idx, tlb_t *tlb)
+static void print_tlb(GString *buf, int idx, tlb_t *tlb)
{
- monitor_printf(mon, " tlb%i:\t"
- "asid=%hhu vpn=%x\tppn=%x\tsz=%hhu size=%u\t"
- "v=%hhu shared=%hhu cached=%hhu prot=%hhu "
- "dirty=%hhu writethrough=%hhu\n",
- idx,
- tlb->asid, tlb->vpn, tlb->ppn, tlb->sz, tlb->size,
- tlb->v, tlb->sh, tlb->c, tlb->pr,
- tlb->d, tlb->wt);
+ g_string_append_printf(buf, " tlb%i:\t"
+ "asid=%hhu vpn=%x\tppn=%x\tsz=%hhu size=%u\t"
+ "v=%hhu shared=%hhu cached=%hhu prot=%hhu "
+ "dirty=%hhu writethrough=%hhu\n",
+ idx,
+ tlb->asid, tlb->vpn, tlb->ppn, tlb->sz, tlb->size,
+ tlb->v, tlb->sh, tlb->c, tlb->pr,
+ tlb->d, tlb->wt);
+}
+
+void superh_cpu_format_tlb(CPUState *cpu, GString *buf)
+{
+ CPUArchState *env = cpu->env_ptr;
+ size_t i;
+
+ g_string_append_printf(buf, "ITLB:\n");
+ for (i = 0 ; i < ITLB_SIZE ; i++) {
+ print_tlb(buf, i, &env->itlb[i]);
+ }
+ g_string_append_printf(buf, "UTLB:\n");
+ for (i = 0 ; i < UTLB_SIZE ; i++) {
+ print_tlb(buf, i, &env->utlb[i]);
+ }
}
void hmp_info_tlb(Monitor *mon, const QDict *qdict)
{
- CPUArchState *env = mon_get_cpu_env(mon);
- int i;
+ g_autoptr(GString) buf = g_string_new("");
+ CPUState *cpu = mon_get_cpu(mon);
- if (!env) {
+ if (!cpu) {
monitor_printf(mon, "No CPU available\n");
return;
}
- monitor_printf (mon, "ITLB:\n");
- for (i = 0 ; i < ITLB_SIZE ; i++)
- print_tlb (mon, i, &env->itlb[i]);
- monitor_printf (mon, "UTLB:\n");
- for (i = 0 ; i < UTLB_SIZE ; i++)
- print_tlb (mon, i, &env->utlb[i]);
+ cpu_format_tlb(cpu, buf);
+
+ monitor_printf(mon, "%s", buf->str);
}
--
2.31.1
- Re: [PATCH v2 42/53] hw/core: introduce a 'format_tlb' callback, (continued)
[PATCH v2 43/53] target/i386: convert to use format_tlb callback, Daniel P . Berrangé, 2021/09/14
[PATCH v2 44/53] target/m68k: convert to use format_tlb callback, Daniel P . Berrangé, 2021/09/14
[PATCH v2 45/53] target/nios2: convert to use format_tlb callback, Daniel P . Berrangé, 2021/09/14
[PATCH v2 46/53] target/ppc: convert to use format_tlb callback, Daniel P . Berrangé, 2021/09/14
[PATCH v2 47/53] target/sh4: convert to use format_tlb callback,
Daniel P . Berrangé <=
[PATCH v2 48/53] target/sparc: convert to use format_tlb callback, Daniel P . Berrangé, 2021/09/14
[PATCH v2 49/53] target/xtensa: convert to use format_tlb callback, Daniel P . Berrangé, 2021/09/14
[PATCH v2 50/53] monitor: merge duplicate "info tlb" handlers, Daniel P . Berrangé, 2021/09/14
[PATCH v2 51/53] qapi: introduce x-query-tlb QMP command, Daniel P . Berrangé, 2021/09/14
[PATCH v2 52/53] qapi: introduce x-query-jit QMP command, Daniel P . Berrangé, 2021/09/14
[PATCH v2 53/53] qapi: introduce x-query-opcount QMP command, Daniel P . Berrangé, 2021/09/14