qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH-for-9.1 11/21] target/nios2: Move monitor commands to monitor.c


From: Philippe Mathieu-Daudé
Subject: [PATCH-for-9.1 11/21] target/nios2: Move monitor commands to monitor.c
Date: Thu, 21 Mar 2024 16:48:27 +0100

Move 'info tlb' monitor commands to monitor.c,
rename dump_mmu() as nios2_info_mmu().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/nios2/cpu.h     |  2 +-
 target/nios2/mmu.c     | 27 ---------------------------
 target/nios2/monitor.c | 28 +++++++++++++++++++++++++++-
 3 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
index 4164a3432e..27e835cf40 100644
--- a/target/nios2/cpu.h
+++ b/target/nios2/cpu.h
@@ -250,7 +250,7 @@ static inline void nios2_update_crs(CPUNios2State *env)
 
 void nios2_tcg_init(void);
 void nios2_cpu_do_interrupt(CPUState *cs);
-void dump_mmu(CPUNios2State *env);
+void nios2_info_mmu(Monitor *mon, CPUNios2State *env);
 void nios2_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
 G_NORETURN void nios2_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
                                               MMUAccessType access_type, int 
mmu_idx,
diff --git a/target/nios2/mmu.c b/target/nios2/mmu.c
index 272bd9fc6a..278eba1b0a 100644
--- a/target/nios2/mmu.c
+++ b/target/nios2/mmu.c
@@ -19,7 +19,6 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu/qemu-print.h"
 #include "cpu.h"
 #include "exec/exec-all.h"
 #include "mmu.h"
@@ -187,29 +186,3 @@ void nios2_mmu_init(CPUNios2State *env)
     mmu->tlb_entry_mask = (cpu->tlb_num_entries / cpu->tlb_num_ways) - 1;
     mmu->tlb = g_new0(Nios2TLBEntry, cpu->tlb_num_entries);
 }
-
-void dump_mmu(CPUNios2State *env)
-{
-    Nios2CPU *cpu = env_archcpu(env);
-    int i;
-
-    qemu_printf("MMU: ways %d, entries %d, pid bits %d\n",
-                cpu->tlb_num_ways, cpu->tlb_num_entries,
-                cpu->pid_num_bits);
-
-    for (i = 0; i < cpu->tlb_num_entries; i++) {
-        Nios2TLBEntry *entry = &env->mmu.tlb[i];
-        qemu_printf("TLB[%d] = %08X %08X %c VPN %05X "
-                    "PID %02X %c PFN %05X %c%c%c%c\n",
-                    i, entry->tag, entry->data,
-                    (entry->tag & (1 << 10)) ? 'V' : '-',
-                    entry->tag >> 12,
-                    entry->tag & ((1 << cpu->pid_num_bits) - 1),
-                    (entry->tag & (1 << 11)) ? 'G' : '-',
-                    FIELD_EX32(entry->data, CR_TLBACC, PFN),
-                    (entry->data & CR_TLBACC_C) ? 'C' : '-',
-                    (entry->data & CR_TLBACC_R) ? 'R' : '-',
-                    (entry->data & CR_TLBACC_W) ? 'W' : '-',
-                    (entry->data & CR_TLBACC_X) ? 'X' : '-');
-    }
-}
diff --git a/target/nios2/monitor.c b/target/nios2/monitor.c
index 0152dec3fa..c6043769e4 100644
--- a/target/nios2/monitor.c
+++ b/target/nios2/monitor.c
@@ -22,14 +22,40 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
+#include "qemu/qemu-print.h"
 #include "cpu.h"
 #include "monitor/monitor.h"
 #include "monitor/hmp-target.h"
 #include "monitor/hmp.h"
 
+void nios2_info_mmu(Monitor *mon, CPUNios2State *env)
+{
+    Nios2CPU *cpu = env_archcpu(env);
+
+    qemu_printf("MMU: ways %d, entries %d, pid bits %d\n",
+                cpu->tlb_num_ways, cpu->tlb_num_entries,
+                cpu->pid_num_bits);
+
+    for (int i = 0; i < cpu->tlb_num_entries; i++) {
+        Nios2TLBEntry *entry = &env->mmu.tlb[i];
+        qemu_printf("TLB[%d] = %08X %08X %c VPN %05X "
+                    "PID %02X %c PFN %05X %c%c%c%c\n",
+                    i, entry->tag, entry->data,
+                    (entry->tag & (1 << 10)) ? 'V' : '-',
+                    entry->tag >> 12,
+                    entry->tag & ((1 << cpu->pid_num_bits) - 1),
+                    (entry->tag & (1 << 11)) ? 'G' : '-',
+                    FIELD_EX32(entry->data, CR_TLBACC, PFN),
+                    (entry->data & CR_TLBACC_C) ? 'C' : '-',
+                    (entry->data & CR_TLBACC_R) ? 'R' : '-',
+                    (entry->data & CR_TLBACC_W) ? 'W' : '-',
+                    (entry->data & CR_TLBACC_X) ? 'X' : '-');
+    }
+}
+
 void hmp_info_tlb(Monitor *mon, const QDict *qdict)
 {
     CPUArchState *env1 = mon_get_cpu_env(mon);
 
-    dump_mmu(env1);
+    nios2_info_mmu(mon, env1);
 }
-- 
2.41.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]