From f9c29217fc9f45f9e4c2b5ae559ddf266184a6ff Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Fri, 19 Sep 2025 18:32:45 +0300 Subject: [PATCH] 68030 MMU debugger table dump --- cpummu30.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++ debug.cpp | 14 ++++++++-- include/cpummu030.h | 1 + 3 files changed, 79 insertions(+), 2 deletions(-) diff --git a/cpummu30.cpp b/cpummu30.cpp index 584c017a..7dd9d80b 100644 --- a/cpummu30.cpp +++ b/cpummu30.cpp @@ -3607,3 +3607,69 @@ void m68k_do_rte_mmu030c (uaecptr a7) } } } + +void mmu030_dump_tables(int fc) +{ + uaecptr addr = 0, phys_c = 0; + uaecptr addr_prev = addr; + uaecptr phys_prev = addr; + uae_u32 desc_prev = 0xffffffff; + uae_u16 status = 0, status_prev = 0; + + console_out_f(_T("FC=%d\n"), fc); + for (;;) { + struct mmu_debug_data *mdd; + + uae_u32 desc = 0xffffffff; + uaecptr phys = 0xffffffff; + TRY(prb) { + phys = debug_mmu030_translate(addr, fc, false, &mdd); + } CATCH(prb) { + } ENDTRY; + for (int i = 0; i < MAX_MMU_DEBUG_DESCRIPTOR_LEVEL; i++) { + if (mdd->descriptor[i] == 0xffffffff) { + break; + } + desc = get_long(mdd->descriptor[i]); + } + status = mmu030.status; + + if (addr == 0) { + desc_prev = desc; + addr_prev = addr; + phys_prev = phys; + phys_c = phys; + status_prev = status; + } + + if (((desc_prev & (DESCR_WP | DESCR_CI | DESCR_TYPE_MASK)) != (desc & (DESCR_WP | DESCR_CI | DESCR_TYPE_MASK))) || + ((status & (MMUSR_SUPER_VIOLATION | MMUSR_WRITE_PROTECTED)) != (status_prev & (MMUSR_SUPER_VIOLATION | MMUSR_WRITE_PROTECTED))) || + (phys_prev != phys && phys_c != phys) || addr + regs.mmu_page_size == 0) { + uaecptr addr_end = addr; + if (addr_end + regs.mmu_page_size == 0) { + addr_end += regs.mmu_page_size; + } + console_out_f(_T("%08x - %08x (%08x) S=%d,WP=%d - CI=%d,WP=%d,DT=%d\n"), + addr_prev, addr_end - 1, desc_prev, + (status_prev & MMUSR_SUPER_VIOLATION) ? 1 : 0, + (status_prev & MMUSR_WRITE_PROTECTED) ? 1 : 0, + (desc_prev >> 6) & 1, + (desc_prev >> 2) & 1, + (desc_prev >> 0) & 3 + ); + desc_prev = desc; + addr_prev = addr; + phys_prev = phys; + phys_c = phys; + status_prev = status; + } + + addr += regs.mmu_page_size; + phys_c += regs.mmu_page_size; + if (addr == 0) { + break; + } + } + + +} diff --git a/debug.cpp b/debug.cpp index 70ae6b5d..2d018698 100644 --- a/debug.cpp +++ b/debug.cpp @@ -6624,7 +6624,7 @@ static void debug_do_mmu_translate(uaecptr addrl) if (desc != 0xffffffff) { descdata = get_long_debug(desc); if ((descdata & 3) == 2) { - console_out_f(_T(" - IND %08x (%08x = %08x,PDT=%d)\n"), + console_out_f(_T(" - IND %08x (%08x = %08x,PDT=%d)\n"), desc, descdata & ~3, descdata & 3); pageidx++; } @@ -7244,8 +7244,18 @@ static bool debug_line (TCHAR *input) if (*inptr == 'm' && inptr[1] == 'u') { inptr += 2; if (inptr[0] == 'd') { - if (currprefs.mmu_model >= 68040) + if (currprefs.mmu_model >= 68040) { mmu_dump_tables(); + } else { + int fc = debug_mmu_mode; + if (more_params(&inptr)) { + fc = readint(&inptr, NULL); + } + if (fc <= 0 || fc > 7) { + fc = 2; + } + mmu030_dump_tables(fc); + } } else { if (currprefs.mmu_model) { if (more_params (&inptr)) diff --git a/include/cpummu030.h b/include/cpummu030.h index 3ccabed0..ba8fc772 100644 --- a/include/cpummu030.h +++ b/include/cpummu030.h @@ -115,6 +115,7 @@ extern void REGPARAM3 mmu030_put_long_unaligned(uaecptr addr, uae_u32 val, uae_u extern uaecptr debug_mmu030_translate(uaecptr addr, int fc, bool write, struct mmu_debug_data **mdd); extern void debug_mmu030_translate_end(void); +extern void mmu030_dump_tables(int fc); static ALWAYS_INLINE uae_u32 uae_mmu030_get_fc_code(void) { -- 2.47.3