From 796b7a2dca8ad9d68c2c7ef0b0957324cf31cdc5 Mon Sep 17 00:00:00 2001 From: Anthony Pesch Date: Wed, 15 Nov 2017 08:35:51 -0500 Subject: [PATCH] added tmu stats debug menu --- src/guest/holly/holly.c | 8 ++++---- src/guest/holly/holly.h | 2 +- src/guest/sh4/sh4.c | 12 ++++++++++-- src/guest/sh4/sh4.h | 4 +++- src/guest/sh4/sh4_mem.c | 4 ++-- src/guest/sh4/sh4_tmu.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/guest/sh4/sh4_tmu.h | 8 ++++++++ 7 files changed, 68 insertions(+), 10 deletions(-) create mode 100644 src/guest/sh4/sh4_tmu.h diff --git a/src/guest/holly/holly.c b/src/guest/holly/holly.c index 34afed18..f8da6e22 100644 --- a/src/guest/holly/holly.c +++ b/src/guest/holly/holly.c @@ -317,7 +317,7 @@ void holly_reg_write(struct holly *hl, uint32_t addr, uint32_t data, uint32_t offset = addr >> 2; reg_write_cb write = holly_cb[offset].write; - if (hl->log_reg_access) { + if (hl->log_regs) { LOG_INFO("holly_reg_write addr=0x%08x data=0x%x", addr, data & mask); } @@ -340,7 +340,7 @@ uint32_t holly_reg_read(struct holly *hl, uint32_t addr, uint32_t mask) { data = hl->reg[offset]; } - if (hl->log_reg_access) { + if (hl->log_regs) { LOG_INFO("holly_reg_read addr=0x%08x data=0x%x", addr, data); } @@ -351,8 +351,8 @@ uint32_t holly_reg_read(struct holly *hl, uint32_t addr, uint32_t mask) { void holly_debug_menu(struct holly *hl) { if (igBeginMainMenuBar()) { if (igBeginMenu("HOLLY", 1)) { - if (igMenuItem("log reg access", NULL, hl->log_reg_access, 1)) { - hl->log_reg_access = !hl->log_reg_access; + if (igMenuItem("log reg access", NULL, hl->log_regs, 1)) { + hl->log_regs = !hl->log_regs; } if (igMenuItem("raise all HOLLY_INT_NRM", NULL, 0, 1)) { diff --git a/src/guest/holly/holly.h b/src/guest/holly/holly.h index d323b595..01bad8b9 100644 --- a/src/guest/holly/holly.h +++ b/src/guest/holly/holly.h @@ -29,7 +29,7 @@ struct holly { struct holly_g2_dma dma[HOLLY_G2_NUM_CHAN]; /* debug */ - int log_reg_access; + int log_regs; }; extern struct reg_cb holly_cb[NUM_HOLLY_REGS]; diff --git a/src/guest/sh4/sh4.c b/src/guest/sh4/sh4.c index cadec0aa..53ff8921 100644 --- a/src/guest/sh4/sh4.c +++ b/src/guest/sh4/sh4.c @@ -296,8 +296,12 @@ void sh4_debug_menu(struct sh4 *sh4) { } } - if (igMenuItem("log reg access", NULL, sh4->log_reg_access, 1)) { - sh4->log_reg_access = !sh4->log_reg_access; + if (igMenuItem("log reg access", NULL, sh4->log_regs, 1)) { + sh4->log_regs = !sh4->log_regs; + } + + if (igMenuItem("tmu stats", NULL, sh4->tmu_stats, 1)) { + sh4->tmu_stats = !sh4->tmu_stats; } igEndMenu(); @@ -305,6 +309,10 @@ void sh4_debug_menu(struct sh4 *sh4) { igEndMainMenuBar(); } + + if (sh4->tmu_stats) { + sh4_tmu_debug_menu(sh4); + } } #endif diff --git a/src/guest/sh4/sh4.h b/src/guest/sh4/sh4.h index 80ffcbe6..1bb23fb1 100644 --- a/src/guest/sh4/sh4.h +++ b/src/guest/sh4/sh4.h @@ -9,6 +9,7 @@ #include "guest/sh4/sh4_mem.h" #include "guest/sh4/sh4_mmu.h" #include "guest/sh4/sh4_scif.h" +#include "guest/sh4/sh4_tmu.h" #include "guest/sh4/sh4_types.h" #include "jit/frontend/sh4/sh4_guest.h" #include "jit/jit.h" @@ -43,7 +44,8 @@ struct sh4 { struct jit_backend *backend; /* dbg */ - int log_reg_access; + int log_regs; + int tmu_stats; struct list breakpoints; /* intc */ diff --git a/src/guest/sh4/sh4_mem.c b/src/guest/sh4/sh4_mem.c index e11c270a..967f919c 100644 --- a/src/guest/sh4/sh4_mem.c +++ b/src/guest/sh4/sh4_mem.c @@ -17,7 +17,7 @@ static uint32_t sh4_reg_read(struct sh4 *sh4, uint32_t addr, uint32_t mask) { data = sh4->reg[offset]; } - if (sh4->log_reg_access) { + if (sh4->log_regs) { LOG_INFO("sh4_reg_read addr=0x%08x data=0x%x", addr, data); } @@ -29,7 +29,7 @@ static void sh4_reg_write(struct sh4 *sh4, uint32_t addr, uint32_t data, uint32_t offset = SH4_REG_OFFSET(addr); reg_write_cb write = sh4_cb[offset].write; - if (sh4->log_reg_access) { + if (sh4->log_regs) { LOG_INFO("sh4_reg_write addr=0x%08x data=0x%x", addr, data & mask); } diff --git a/src/guest/sh4/sh4_tmu.c b/src/guest/sh4/sh4_tmu.c index e02f22c6..3895566d 100644 --- a/src/guest/sh4/sh4_tmu.c +++ b/src/guest/sh4/sh4_tmu.c @@ -1,5 +1,7 @@ +#include "guest/sh4/sh4_tmu.h" #include "guest/scheduler.h" #include "guest/sh4/sh4.h" +#include "imgui.h" static const int64_t PERIPHERAL_CLOCK_FREQ = SH4_CLOCK_FREQ >> 2; static const int PERIPHERAL_SCALE[] = {2, 4, 6, 8, 10, 0, 0, 0}; @@ -133,6 +135,44 @@ static void sh4_tmu_update_tcnt(struct sh4 *sh4, uint32_t n) { } } +#ifdef HAVE_IMGUI +void sh4_tmu_debug_menu(struct sh4 *sh4) { + if (igBegin("tmu stats", NULL, 0)) { + igColumns(6, NULL, 0); + + igText("#"); + igNextColumn(); + igText("started"); + igNextColumn(); + igText("count"); + igNextColumn(); + igText("control"); + igNextColumn(); + igText("reset count"); + igNextColumn(); + igText("underflowed"); + igNextColumn(); + + for (int i = 0; i < 3; i++) { + igText("%d", i); + igNextColumn(); + igText(TSTR(i) ? "yes" : "no"); + igNextColumn(); + igText("0x%08x", sh4_tmu_tcnt(sh4, i)); + igNextColumn(); + igText("0x%08x", TCR(i)); + igNextColumn(); + igText("0x%08x", TCOR(i)); + igNextColumn(); + igText("0x%x", TUNI(i)); + igNextColumn(); + } + + igEnd(); + } +} +#endif + REG_W32(sh4_cb, TSTR) { struct sh4 *sh4 = dc->sh4; *sh4->TSTR = value; diff --git a/src/guest/sh4/sh4_tmu.h b/src/guest/sh4/sh4_tmu.h new file mode 100644 index 00000000..5c16a5f0 --- /dev/null +++ b/src/guest/sh4/sh4_tmu.h @@ -0,0 +1,8 @@ +#ifndef SH4_TMU_H +#define SH4_TMU_H + +struct sh4; + +void sh4_tmu_debug_menu(struct sh4 *sh4); + +#endif