diff mbox

[6/8] disas: sh4: QOMify target specific disas setup

Message ID 018228a9283281e2d91ce255e219f5244479d703.1436665556.git.crosthwaite.peter@gmail.com
State New
Headers show

Commit Message

Peter Crosthwaite July 12, 2015, 2 a.m. UTC
From: Peter Crosthwaite <crosthwaitepeter@gmail.com>

Move the target_disas() sh4 specifics to the QOM disas_set_info hook
and delete the #ifdef specific code in disas.c.

Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
Testing:
$ ../../qemu/sh4-softmmu/qemu-system-sh4 -M r2d -kernel zImage \
    -hda sh-linux-mini.img -nographic -d in_asm -S 2> err
QEMU 2.3.90 monitor - type 'help' for more information
(qemu) info registers
pc=0xac800000 sr=0x700000f0 pr=0x00000000 fpscr=0x00040001
...
(qemu) x/i 0xac800000
0xac800000:  mov.l  0xac80007c,r1   ! 0x400000f0
(qemu) x/i 0xac800004
0xac800004:  mova   0xac80004c,r0
(qemu) c
(qemu) q

$ more err
IN:
0xac800000:  mov.l  0xac80007c,r1   ! 0x400000f0
0xac800002:  ldc    r1,sr

IN:
0xac800004:  mova   0xac80004c,r0
---
 disas.c          | 6 ------
 target-sh4/cpu.c | 8 ++++++++
 2 files changed, 8 insertions(+), 6 deletions(-)

Comments

Aurelien Jarno July 14, 2015, 3:47 p.m. UTC | #1
On 2015-07-11 19:00, Peter Crosthwaite wrote:
> From: Peter Crosthwaite <crosthwaitepeter@gmail.com>
> 
> Move the target_disas() sh4 specifics to the QOM disas_set_info hook
> and delete the #ifdef specific code in disas.c.
> 
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
> ---
> Testing:
> $ ../../qemu/sh4-softmmu/qemu-system-sh4 -M r2d -kernel zImage \
>     -hda sh-linux-mini.img -nographic -d in_asm -S 2> err
> QEMU 2.3.90 monitor - type 'help' for more information
> (qemu) info registers
> pc=0xac800000 sr=0x700000f0 pr=0x00000000 fpscr=0x00040001
> ...
> (qemu) x/i 0xac800000
> 0xac800000:  mov.l  0xac80007c,r1   ! 0x400000f0
> (qemu) x/i 0xac800004
> 0xac800004:  mova   0xac80004c,r0
> (qemu) c
> (qemu) q
> 
> $ more err
> IN:
> 0xac800000:  mov.l  0xac80007c,r1   ! 0x400000f0
> 0xac800002:  ldc    r1,sr
> 
> IN:
> 0xac800004:  mova   0xac80004c,r0
> ---
>  disas.c          | 6 ------
>  target-sh4/cpu.c | 8 ++++++++
>  2 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/disas.c b/disas.c
> index f269cc9..eee369e 100644
> --- a/disas.c
> +++ b/disas.c
> @@ -244,9 +244,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;
> @@ -454,9 +451,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 5c65ab4..1b4289d 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;
> @@ -290,6 +296,8 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data)
>  #endif
>      dc->vmsd = &vmstate_sh_cpu;
>      cc->gdb_num_core_regs = 59;
> +
> +    cc->disas_set_info = superh_cpu_disas_set_info;
>  }
>  
>  static const TypeInfo superh_cpu_type_info = {

Acked-by: Aurelien Jarno <aurelien@aurel32.net>
diff mbox

Patch

diff --git a/disas.c b/disas.c
index f269cc9..eee369e 100644
--- a/disas.c
+++ b/disas.c
@@ -244,9 +244,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;
@@ -454,9 +451,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 5c65ab4..1b4289d 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;
@@ -290,6 +296,8 @@  static void superh_cpu_class_init(ObjectClass *oc, void *data)
 #endif
     dc->vmsd = &vmstate_sh_cpu;
     cc->gdb_num_core_regs = 59;
+
+    cc->disas_set_info = superh_cpu_disas_set_info;
 }
 
 static const TypeInfo superh_cpu_type_info = {