diff options
author | Markus Armbruster <armbru@redhat.com> | 2019-04-17 21:17:58 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2019-04-18 22:18:59 +0200 |
commit | fad866daa85c65267fa44de40f10cc1ee904ae1a (patch) | |
tree | b94800a130298a2a9f6d9f41ad5692bf5fa6964e /target/m68k | |
parent | 0442428a8976b4f94e04d24b5db9eb1b678d82c4 (diff) |
target: Clean up how the dump_mmu() print
The various dump_mmu() take an fprintf()-like callback and a FILE * to
pass to it, and so do their helper functions. Passing around callback
and argument is rather tiresome.
Most dump_mmu() are called only by the target's hmp_info_tlb(). These
all pass monitor_printf() cast to fprintf_function and the current
monitor cast to FILE *.
SPARC's dump_mmu() gets also called from target/sparc/ldst_helper.c a
few times #ifdef DEBUG_MMU. These calls pass fprintf() and stdout.
The type-punning is technically undefined behaviour, but works in
practice. Clean up: drop the callback, and call qemu_printf()
instead.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190417191805.28198-11-armbru@redhat.com>
Diffstat (limited to 'target/m68k')
-rw-r--r-- | target/m68k/cpu.h | 3 | ||||
-rw-r--r-- | target/m68k/helper.c | 115 | ||||
-rw-r--r-- | target/m68k/monitor.c | 2 |
3 files changed, 59 insertions, 61 deletions
diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index 9c1f0a2458..73952f6ece 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -573,5 +573,6 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *env, target_ulong *pc, } } -void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUM68KState *env); +void dump_mmu(CPUM68KState *env); + #endif diff --git a/target/m68k/helper.c b/target/m68k/helper.c index bb64cf15c0..d958a34959 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -369,30 +369,28 @@ int m68k_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, /* MMU: 68040 only */ -static void print_address_zone(FILE *f, fprintf_function cpu_fprintf, - uint32_t logical, uint32_t physical, +static void print_address_zone(uint32_t logical, uint32_t physical, uint32_t size, int attr) { - cpu_fprintf(f, "%08x - %08x -> %08x - %08x %c ", + qemu_printf("%08x - %08x -> %08x - %08x %c ", logical, logical + size - 1, physical, physical + size - 1, attr & 4 ? 'W' : '-'); size >>= 10; if (size < 1024) { - cpu_fprintf(f, "(%d KiB)\n", size); + qemu_printf("(%d KiB)\n", size); } else { size >>= 10; if (size < 1024) { - cpu_fprintf(f, "(%d MiB)\n", size); + qemu_printf("(%d MiB)\n", size); } else { size >>= 10; - cpu_fprintf(f, "(%d GiB)\n", size); + qemu_printf("(%d GiB)\n", size); } } } -static void dump_address_map(FILE *f, fprintf_function cpu_fprintf, - CPUM68KState *env, uint32_t root_pointer) +static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) { int i, j, k; int tic_size, tic_shift; @@ -454,7 +452,7 @@ static void dump_address_map(FILE *f, fprintf_function cpu_fprintf, if (first_logical != 0xffffffff) { size = last_logical + (1 << tic_shift) - first_logical; - print_address_zone(f, cpu_fprintf, first_logical, + print_address_zone(first_logical, first_physical, size, last_attr); } first_logical = logical; @@ -465,126 +463,125 @@ static void dump_address_map(FILE *f, fprintf_function cpu_fprintf, } if (first_logical != logical || (attr & 4) != (last_attr & 4)) { size = logical + (1 << tic_shift) - first_logical; - print_address_zone(f, cpu_fprintf, first_logical, first_physical, size, - last_attr); + print_address_zone(first_logical, first_physical, size, last_attr); } } #define DUMP_CACHEFLAGS(a) \ switch (a & M68K_DESC_CACHEMODE) { \ case M68K_DESC_CM_WRTHRU: /* cachable, write-through */ \ - cpu_fprintf(f, "T"); \ + qemu_printf("T"); \ break; \ case M68K_DESC_CM_COPYBK: /* cachable, copyback */ \ - cpu_fprintf(f, "C"); \ + qemu_printf("C"); \ break; \ case M68K_DESC_CM_SERIAL: /* noncachable, serialized */ \ - cpu_fprintf(f, "S"); \ + qemu_printf("S"); \ break; \ case M68K_DESC_CM_NCACHE: /* noncachable */ \ - cpu_fprintf(f, "N"); \ + qemu_printf("N"); \ break; \ } -static void dump_ttr(FILE *f, fprintf_function cpu_fprintf, uint32_t ttr) +static void dump_ttr(uint32_t ttr) { if ((ttr & M68K_TTR_ENABLED) == 0) { - cpu_fprintf(f, "disabled\n"); + qemu_printf("disabled\n"); return; } - cpu_fprintf(f, "Base: 0x%08x Mask: 0x%08x Control: ", + qemu_printf("Base: 0x%08x Mask: 0x%08x Control: ", ttr & M68K_TTR_ADDR_BASE, (ttr & M68K_TTR_ADDR_MASK) << M68K_TTR_ADDR_MASK_SHIFT); switch (ttr & M68K_TTR_SFIELD) { case M68K_TTR_SFIELD_USER: - cpu_fprintf(f, "U"); + qemu_printf("U"); break; case M68K_TTR_SFIELD_SUPER: - cpu_fprintf(f, "S"); + qemu_printf("S"); break; default: - cpu_fprintf(f, "*"); + qemu_printf("*"); break; } DUMP_CACHEFLAGS(ttr); if (ttr & M68K_DESC_WRITEPROT) { - cpu_fprintf(f, "R"); + qemu_printf("R"); } else { - cpu_fprintf(f, "W"); + qemu_printf("W"); } - cpu_fprintf(f, " U: %d\n", (ttr & M68K_DESC_USERATTR) >> + qemu_printf(" U: %d\n", (ttr & M68K_DESC_USERATTR) >> M68K_DESC_USERATTR_SHIFT); } -void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUM68KState *env) +void dump_mmu(CPUM68KState *env) { if ((env->mmu.tcr & M68K_TCR_ENABLED) == 0) { - cpu_fprintf(f, "Translation disabled\n"); + qemu_printf("Translation disabled\n"); return; } - cpu_fprintf(f, "Page Size: "); + qemu_printf("Page Size: "); if (env->mmu.tcr & M68K_TCR_PAGE_8K) { - cpu_fprintf(f, "8kB\n"); + qemu_printf("8kB\n"); } else { - cpu_fprintf(f, "4kB\n"); + qemu_printf("4kB\n"); } - cpu_fprintf(f, "MMUSR: "); + qemu_printf("MMUSR: "); if (env->mmu.mmusr & M68K_MMU_B_040) { - cpu_fprintf(f, "BUS ERROR\n"); + qemu_printf("BUS ERROR\n"); } else { - cpu_fprintf(f, "Phy=%08x Flags: ", env->mmu.mmusr & 0xfffff000); + qemu_printf("Phy=%08x Flags: ", env->mmu.mmusr & 0xfffff000); /* flags found on the page descriptor */ if (env->mmu.mmusr & M68K_MMU_G_040) { - cpu_fprintf(f, "G"); /* Global */ + qemu_printf("G"); /* Global */ } else { - cpu_fprintf(f, "."); + qemu_printf("."); } if (env->mmu.mmusr & M68K_MMU_S_040) { - cpu_fprintf(f, "S"); /* Supervisor */ + qemu_printf("S"); /* Supervisor */ } else { - cpu_fprintf(f, "."); + qemu_printf("."); } if (env->mmu.mmusr & M68K_MMU_M_040) { - cpu_fprintf(f, "M"); /* Modified */ + qemu_printf("M"); /* Modified */ } else { - cpu_fprintf(f, "."); + qemu_printf("."); } if (env->mmu.mmusr & M68K_MMU_WP_040) { - cpu_fprintf(f, "W"); /* Write protect */ + qemu_printf("W"); /* Write protect */ } else { - cpu_fprintf(f, "."); + qemu_printf("."); } if (env->mmu.mmusr & M68K_MMU_T_040) { - cpu_fprintf(f, "T"); /* Transparent */ + qemu_printf("T"); /* Transparent */ } else { - cpu_fprintf(f, "."); + qemu_printf("."); } if (env->mmu.mmusr & M68K_MMU_R_040) { - cpu_fprintf(f, "R"); /* Resident */ + qemu_printf("R"); /* Resident */ } else { - cpu_fprintf(f, "."); + qemu_printf("."); } - cpu_fprintf(f, " Cache: "); + qemu_printf(" Cache: "); DUMP_CACHEFLAGS(env->mmu.mmusr); - cpu_fprintf(f, " U: %d\n", (env->mmu.mmusr >> 8) & 3); - cpu_fprintf(f, "\n"); + qemu_printf(" U: %d\n", (env->mmu.mmusr >> 8) & 3); + qemu_printf("\n"); } - cpu_fprintf(f, "ITTR0: "); - dump_ttr(f, cpu_fprintf, env->mmu.ttr[M68K_ITTR0]); - cpu_fprintf(f, "ITTR1: "); - dump_ttr(f, cpu_fprintf, env->mmu.ttr[M68K_ITTR1]); - cpu_fprintf(f, "DTTR0: "); - dump_ttr(f, cpu_fprintf, env->mmu.ttr[M68K_DTTR0]); - cpu_fprintf(f, "DTTR1: "); - dump_ttr(f, cpu_fprintf, env->mmu.ttr[M68K_DTTR1]); + qemu_printf("ITTR0: "); + dump_ttr(env->mmu.ttr[M68K_ITTR0]); + qemu_printf("ITTR1: "); + dump_ttr(env->mmu.ttr[M68K_ITTR1]); + qemu_printf("DTTR0: "); + dump_ttr(env->mmu.ttr[M68K_DTTR0]); + qemu_printf("DTTR1: "); + dump_ttr(env->mmu.ttr[M68K_DTTR1]); - cpu_fprintf(f, "SRP: 0x%08x\n", env->mmu.srp); - dump_address_map(f, cpu_fprintf, env, env->mmu.srp); + qemu_printf("SRP: 0x%08x\n", env->mmu.srp); + dump_address_map(env, env->mmu.srp); - cpu_fprintf(f, "URP: 0x%08x\n", env->mmu.urp); - dump_address_map(f, cpu_fprintf, env, env->mmu.urp); + qemu_printf("URP: 0x%08x\n", env->mmu.urp); + dump_address_map(env, env->mmu.urp); } static int check_TTR(uint32_t ttr, int *prot, target_ulong addr, diff --git a/target/m68k/monitor.c b/target/m68k/monitor.c index db582a34ac..2055fe8a00 100644 --- a/target/m68k/monitor.c +++ b/target/m68k/monitor.c @@ -19,7 +19,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) return; } - dump_mmu((FILE *)mon, (fprintf_function)monitor_printf, env1); + dump_mmu(env1); } static const MonitorDef monitor_defs[] = { |