From dbad6b74b3de6ce839bd870657b6bcc192e3b74a Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Sat, 11 Jul 2015 18:59:58 -0700 Subject: [PATCH 1/8] disas: QOMify s390x specific disas setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the target_disas() s390 specifics to the CPUClass::disas_set_info() hook and delete the #ifdef specific code in disas.c. Cc: Alexander Graf Signed-off-by: Peter Crosthwaite Acked-by: Richard Henderson Signed-off-by: Andreas Färber --- disas.c | 6 ------ target-s390x/cpu.c | 8 ++++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/disas.c b/disas.c index 45878fad2f..655f23d30d 100644 --- a/disas.c +++ b/disas.c @@ -249,9 +249,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, #elif defined(TARGET_ALPHA) s.info.mach = bfd_mach_alpha_ev6; s.info.print_insn = print_insn_alpha; -#elif defined(TARGET_S390X) - s.info.mach = bfd_mach_s390_64; - s.info.print_insn = print_insn_s390; #elif defined(TARGET_MOXIE) s.info.mach = bfd_arch_moxie; s.info.print_insn = print_insn_moxie; @@ -462,9 +459,6 @@ void monitor_disas(Monitor *mon, CPUState *cpu, #elif defined(TARGET_SH4) s.info.mach = bfd_mach_sh4; s.info.print_insn = print_insn_sh; -#elif defined(TARGET_S390X) - s.info.mach = bfd_mach_s390_64; - s.info.print_insn = print_insn_s390; #elif defined(TARGET_MOXIE) s.info.mach = bfd_arch_moxie; s.info.print_insn = print_insn_moxie; diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index ccfaa8a919..189a2afc0f 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -184,6 +184,12 @@ static void s390_cpu_machine_reset_cb(void *opaque) } #endif +static void s390_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) +{ + info->mach = bfd_mach_s390_64; + info->print_insn = print_insn_s390; +} + static void s390_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs = CPU(dev); @@ -351,6 +357,8 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->cpu_exec_interrupt = s390_cpu_exec_interrupt; cc->debug_excp_handler = s390x_cpu_debug_excp_handler; #endif + cc->disas_set_info = s390_cpu_disas_set_info; + cc->gdb_num_core_regs = S390_NUM_CORE_REGS; cc->gdb_core_xml_file = "s390x-core64.xml"; From 9f87a4cacd397e82e80c9512627ce5e190dfa971 Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Sat, 11 Jul 2015 18:59:59 -0700 Subject: [PATCH 2/8] disas: QOMify moxie specific disas setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the target_disas() moxie specifics to the CPUClass::disas_set_info() hook and delete the #ifdef specific code in disas.c. Cc: Anthony Green Signed-off-by: Peter Crosthwaite Signed-off-by: Andreas Färber --- disas.c | 6 ------ target-moxie/cpu.c | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/disas.c b/disas.c index 655f23d30d..05d409b195 100644 --- a/disas.c +++ b/disas.c @@ -249,9 +249,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, #elif defined(TARGET_ALPHA) s.info.mach = bfd_mach_alpha_ev6; s.info.print_insn = print_insn_alpha; -#elif defined(TARGET_MOXIE) - s.info.mach = bfd_arch_moxie; - s.info.print_insn = print_insn_moxie; #elif defined(TARGET_LM32) s.info.mach = bfd_mach_lm32; s.info.print_insn = print_insn_lm32; @@ -459,9 +456,6 @@ void monitor_disas(Monitor *mon, CPUState *cpu, #elif defined(TARGET_SH4) s.info.mach = bfd_mach_sh4; s.info.print_insn = print_insn_sh; -#elif defined(TARGET_MOXIE) - s.info.mach = bfd_arch_moxie; - s.info.print_insn = print_insn_moxie; #elif defined(TARGET_LM32) s.info.mach = bfd_mach_lm32; s.info.print_insn = print_insn_lm32; diff --git a/target-moxie/cpu.c b/target-moxie/cpu.c index 3af37799b7..0c60c65d31 100644 --- a/target-moxie/cpu.c +++ b/target-moxie/cpu.c @@ -48,6 +48,12 @@ static void moxie_cpu_reset(CPUState *s) tlb_flush(s, 1); } +static void moxie_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) +{ + info->mach = bfd_arch_moxie; + info->print_insn = print_insn_moxie; +} + static void moxie_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs = CPU(dev); @@ -114,6 +120,7 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug; cc->vmsd = &vmstate_moxie_cpu; #endif + cc->disas_set_info = moxie_cpu_disas_set_info; /* * Reason: moxie_cpu_initfn() calls cpu_exec_init(), which saves From 4f669905d95bbb6296338f9e86ffcdd8eae453d2 Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Sat, 11 Jul 2015 19:00:00 -0700 Subject: [PATCH 3/8] disas: QOMify m68k specific disas setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the target_disas() m68k specifics to the CPUClass::disas_set_info() hook and delete the #ifdef specific code in disas.c. Signed-off-by: Peter Crosthwaite Reviewed-by: Laurent Vivier Reviewed-by: Greg Ungerer Signed-off-by: Andreas Färber --- disas.c | 4 ---- target-m68k/cpu.c | 9 ++++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/disas.c b/disas.c index 05d409b195..1ef259632e 100644 --- a/disas.c +++ b/disas.c @@ -235,8 +235,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, } s.info.disassembler_options = (char *)"any"; s.info.print_insn = print_insn_ppc; -#elif defined(TARGET_M68K) - s.info.print_insn = print_insn_m68k; #elif defined(TARGET_MIPS) #ifdef TARGET_WORDS_BIGENDIAN s.info.print_insn = print_insn_big_mips; @@ -445,8 +443,6 @@ void monitor_disas(Monitor *mon, CPUState *cpu, s.info.endian = BFD_ENDIAN_LITTLE; } s.info.print_insn = print_insn_ppc; -#elif defined(TARGET_M68K) - s.info.print_insn = print_insn_m68k; #elif defined(TARGET_MIPS) #ifdef TARGET_WORDS_BIGENDIAN s.info.print_insn = print_insn_big_mips; diff --git a/target-m68k/cpu.c b/target-m68k/cpu.c index 97527ef32a..e8a4eed1f9 100644 --- a/target-m68k/cpu.c +++ b/target-m68k/cpu.c @@ -61,6 +61,11 @@ static void m68k_cpu_reset(CPUState *s) tlb_flush(s, 1); } +static void m68k_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) +{ + info->print_insn = print_insn_m68k; +} + /* CPU models */ static ObjectClass *m68k_cpu_class_by_name(const char *cpu_model) @@ -208,11 +213,13 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) #endif cc->cpu_exec_enter = m68k_cpu_exec_enter; cc->cpu_exec_exit = m68k_cpu_exec_exit; + cc->disas_set_info = m68k_cpu_disas_set_info; - dc->vmsd = &vmstate_m68k_cpu; cc->gdb_num_core_regs = 18; cc->gdb_core_xml_file = "cf-core.xml"; + dc->vmsd = &vmstate_m68k_cpu; + /* * Reason: m68k_cpu_initfn() calls cpu_exec_init(), which saves * the object in cpus -> dangling pointer after final From df0900eb89a0672a3f924b7e8d20163dee2383db Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Sat, 11 Jul 2015 19:00:01 -0700 Subject: [PATCH 4/8] disas: QOMify sparc specific disas setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the target_disas() sparc specifics to the QOM disas_set_info hook and delete the #ifdef specific code in disas.c. Cc: Mark Cave-Ayland Signed-off-by: Peter Crosthwaite Signed-off-by: Andreas Färber --- disas.c | 10 ---------- target-sparc/cpu.c | 9 +++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/disas.c b/disas.c index 1ef259632e..5b3acf0324 100644 --- a/disas.c +++ b/disas.c @@ -214,11 +214,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, s.info.mach = bfd_mach_i386_i386; } s.info.print_insn = print_insn_i386; -#elif defined(TARGET_SPARC) - s.info.print_insn = print_insn_sparc; -#ifdef TARGET_SPARC64 - s.info.mach = bfd_mach_sparc_v9b; -#endif #elif defined(TARGET_PPC) if ((flags >> 16) & 1) { s.info.endian = BFD_ENDIAN_LITTLE; @@ -423,11 +418,6 @@ void monitor_disas(Monitor *mon, CPUState *cpu, s.info.print_insn = print_insn_i386; #elif defined(TARGET_ALPHA) s.info.print_insn = print_insn_alpha; -#elif defined(TARGET_SPARC) - s.info.print_insn = print_insn_sparc; -#ifdef TARGET_SPARC64 - s.info.mach = bfd_mach_sparc_v9b; -#endif #elif defined(TARGET_PPC) if (flags & 0xFFFF) { /* If we have a precise definition of the instruction set, use it. */ diff --git a/target-sparc/cpu.c b/target-sparc/cpu.c index 82bb72ab79..d98682b563 100644 --- a/target-sparc/cpu.c +++ b/target-sparc/cpu.c @@ -90,6 +90,14 @@ static bool sparc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) return false; } +static void cpu_sparc_disas_set_info(CPUState *cpu, disassemble_info *info) +{ + info->print_insn = print_insn_sparc; +#ifdef TARGET_SPARC64 + info->mach = bfd_mach_sparc_v9b; +#endif +} + static int cpu_sparc_register(SPARCCPU *cpu, const char *cpu_model) { CPUClass *cc = CPU_GET_CLASS(cpu); @@ -848,6 +856,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->do_unaligned_access = sparc_cpu_do_unaligned_access; cc->get_phys_page_debug = sparc_cpu_get_phys_page_debug; #endif + cc->disas_set_info = cpu_sparc_disas_set_info; #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) cc->gdb_num_core_regs = 86; From 20984673e68ebd069222512c876b846ff2425cc0 Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Sat, 11 Jul 2015 19:00:02 -0700 Subject: [PATCH 5/8] disas: QOMify lm32 specific disas setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the target_disas() lm32 specifics to the CPUClass::disas_set_info() hook and delete the #ifdef specific code in disas.c. Signed-off-by: Peter Crosthwaite Acked-by: Michael Walle Signed-off-by: Andreas Färber --- disas.c | 6 ------ target-lm32/cpu.c | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/disas.c b/disas.c index 5b3acf0324..b687c98a70 100644 --- a/disas.c +++ b/disas.c @@ -242,9 +242,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, #elif defined(TARGET_ALPHA) s.info.mach = bfd_mach_alpha_ev6; s.info.print_insn = print_insn_alpha; -#elif defined(TARGET_LM32) - s.info.mach = bfd_mach_lm32; - s.info.print_insn = print_insn_lm32; #endif if (s.info.print_insn == NULL) { s.info.print_insn = print_insn_od_target; @@ -442,9 +439,6 @@ void monitor_disas(Monitor *mon, CPUState *cpu, #elif defined(TARGET_SH4) s.info.mach = bfd_mach_sh4; s.info.print_insn = print_insn_sh; -#elif defined(TARGET_LM32) - s.info.mach = bfd_mach_lm32; - s.info.print_insn = print_insn_lm32; #endif if (!s.info.print_insn) { monitor_printf(mon, "0x" TARGET_FMT_lx diff --git a/target-lm32/cpu.c b/target-lm32/cpu.c index d0ab2786ae..0bc544c1e0 100644 --- a/target-lm32/cpu.c +++ b/target-lm32/cpu.c @@ -131,6 +131,12 @@ static void lm32_cpu_reset(CPUState *s) tlb_flush(s, 1); } +static void lm32_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) +{ + info->mach = bfd_mach_lm32; + info->print_insn = print_insn_lm32; +} + static void lm32_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs = CPU(dev); @@ -275,6 +281,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_num_core_regs = 32 + 7; cc->gdb_stop_before_watchpoint = true; cc->debug_excp_handler = lm32_debug_excp_handler; + cc->disas_set_info = lm32_cpu_disas_set_info; /* * Reason: lm32_cpu_initfn() calls cpu_exec_init(), which saves From d49dd523e459a4c001a0c87a438fd2fa1f5b4bae Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Sat, 11 Jul 2015 19:00:03 -0700 Subject: [PATCH 6/8] disas: QOMify sh4 specific disas setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the target_disas() sh4 specifics to the CPUClass::disas_set_info() hook and delete the #ifdef specific code in disas.c. Signed-off-by: Peter Crosthwaite Acked-by: Aurelien Jarno Signed-off-by: Andreas Färber --- disas.c | 6 ------ target-sh4/cpu.c | 11 ++++++++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/disas.c b/disas.c index b687c98a70..2676e2f22a 100644 --- a/disas.c +++ b/disas.c @@ -236,9 +236,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, #else s.info.print_insn = print_insn_little_mips; #endif -#elif defined(TARGET_SH4) - s.info.mach = bfd_mach_sh4; - s.info.print_insn = print_insn_sh; #elif defined(TARGET_ALPHA) s.info.mach = bfd_mach_alpha_ev6; s.info.print_insn = print_insn_alpha; @@ -436,9 +433,6 @@ void monitor_disas(Monitor *mon, CPUState *cpu, #else s.info.print_insn = print_insn_little_mips; #endif -#elif defined(TARGET_SH4) - s.info.mach = bfd_mach_sh4; - s.info.print_insn = print_insn_sh; #endif if (!s.info.print_insn) { monitor_printf(mon, "0x" TARGET_FMT_lx diff --git a/target-sh4/cpu.c b/target-sh4/cpu.c index 64e4467c04..d7e2fbd0ed 100644 --- a/target-sh4/cpu.c +++ b/target-sh4/cpu.c @@ -70,6 +70,12 @@ static void superh_cpu_reset(CPUState *s) set_default_nan_mode(1, &env->fp_status); } +static void superh_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) +{ + info->mach = bfd_mach_sh4; + info->print_insn = print_insn_sh; +} + typedef struct SuperHCPUListState { fprintf_function cpu_fprintf; FILE *file; @@ -288,9 +294,12 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) #else cc->get_phys_page_debug = superh_cpu_get_phys_page_debug; #endif - dc->vmsd = &vmstate_sh_cpu; + cc->disas_set_info = superh_cpu_disas_set_info; + cc->gdb_num_core_regs = 59; + dc->vmsd = &vmstate_sh_cpu; + /* * Reason: superh_cpu_initfn() calls cpu_exec_init(), which saves * the object in cpus -> dangling pointer after final From 63a946c7e3b081d56e617bf264fcb2881a982848 Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Sat, 11 Jul 2015 19:00:04 -0700 Subject: [PATCH 7/8] disas: QOMify mips specific disas setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the target_disas() mips specifics to the CPUClass::disas_set_info() hook and delete the #ifdef specific code in disas.c. Cc: Aurelien Jarno Signed-off-by: Peter Crosthwaite Acked-by: Leon Alrae Signed-off-by: Andreas Färber --- disas.c | 12 ------------ target-mips/cpu.c | 9 +++++++++ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/disas.c b/disas.c index 2676e2f22a..bf16c42dbb 100644 --- a/disas.c +++ b/disas.c @@ -230,12 +230,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, } s.info.disassembler_options = (char *)"any"; s.info.print_insn = print_insn_ppc; -#elif defined(TARGET_MIPS) -#ifdef TARGET_WORDS_BIGENDIAN - s.info.print_insn = print_insn_big_mips; -#else - s.info.print_insn = print_insn_little_mips; -#endif #elif defined(TARGET_ALPHA) s.info.mach = bfd_mach_alpha_ev6; s.info.print_insn = print_insn_alpha; @@ -427,12 +421,6 @@ void monitor_disas(Monitor *mon, CPUState *cpu, s.info.endian = BFD_ENDIAN_LITTLE; } s.info.print_insn = print_insn_ppc; -#elif defined(TARGET_MIPS) -#ifdef TARGET_WORDS_BIGENDIAN - s.info.print_insn = print_insn_big_mips; -#else - s.info.print_insn = print_insn_little_mips; -#endif #endif if (!s.info.print_insn) { monitor_printf(mon, "0x" TARGET_FMT_lx diff --git a/target-mips/cpu.c b/target-mips/cpu.c index 7fe1f0407f..37880d20e0 100644 --- a/target-mips/cpu.c +++ b/target-mips/cpu.c @@ -97,6 +97,14 @@ static void mips_cpu_reset(CPUState *s) #endif } +static void mips_cpu_disas_set_info(CPUState *s, disassemble_info *info) { +#ifdef TARGET_WORDS_BIGENDIAN + info->print_insn = print_insn_big_mips; +#else + info->print_insn = print_insn_little_mips; +#endif +} + static void mips_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs = CPU(dev); @@ -150,6 +158,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->get_phys_page_debug = mips_cpu_get_phys_page_debug; cc->vmsd = &vmstate_mips_cpu; #endif + cc->disas_set_info = mips_cpu_disas_set_info; cc->gdb_num_core_regs = 73; cc->gdb_stop_before_watchpoint = true; From 0960be7cffa7b30189f2f0f76b1ac3c8115660f3 Mon Sep 17 00:00:00 2001 From: Peter Crosthwaite Date: Sat, 11 Jul 2015 19:00:05 -0700 Subject: [PATCH 8/8] disas: QOMify alpha specific disas setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the target_disas() alpha specifics to the CPUClass::disas_set_info() hook and delete the #ifdef specific code in disas.c. This also makes monitor_disas() consistent with target_disas(), as monitor_disas() was missing a set of the BFD (This was an omission from commit b9bec751c8c8b08d8055da32306eb105db03031b). Signed-off-by: Peter Crosthwaite Acked-by: Richard Henderson Signed-off-by: Andreas Färber --- disas.c | 5 ----- target-alpha/cpu.c | 8 ++++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/disas.c b/disas.c index bf16c42dbb..4e119449e8 100644 --- a/disas.c +++ b/disas.c @@ -230,9 +230,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, } s.info.disassembler_options = (char *)"any"; s.info.print_insn = print_insn_ppc; -#elif defined(TARGET_ALPHA) - s.info.mach = bfd_mach_alpha_ev6; - s.info.print_insn = print_insn_alpha; #endif if (s.info.print_insn == NULL) { s.info.print_insn = print_insn_od_target; @@ -404,8 +401,6 @@ void monitor_disas(Monitor *mon, CPUState *cpu, s.info.mach = bfd_mach_i386_i386; } s.info.print_insn = print_insn_i386; -#elif defined(TARGET_ALPHA) - s.info.print_insn = print_insn_alpha; #elif defined(TARGET_PPC) if (flags & 0xFFFF) { /* If we have a precise definition of the instruction set, use it. */ diff --git a/target-alpha/cpu.c b/target-alpha/cpu.c index ff1926a5d0..e5bdfa8ca2 100644 --- a/target-alpha/cpu.c +++ b/target-alpha/cpu.c @@ -46,6 +46,12 @@ static bool alpha_cpu_has_work(CPUState *cs) | CPU_INTERRUPT_MCHK); } +static void alpha_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) +{ + info->mach = bfd_mach_alpha_ev6; + info->print_insn = print_insn_alpha; +} + static void alpha_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs = CPU(dev); @@ -297,6 +303,8 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug; dc->vmsd = &vmstate_alpha_cpu; #endif + cc->disas_set_info = alpha_cpu_disas_set_info; + cc->gdb_num_core_regs = 67; /*