All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH for-2.11 12/27] m68k: replace cpu_m68k_init() with cpu_generic_init()
Date: Fri, 18 Aug 2017 12:08:44 +0200	[thread overview]
Message-ID: <1503050939-227939-13-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1503050939-227939-1-git-send-email-imammedo@redhat.com>

call register_m68k_insns() at realize time which makes
cpu_m68k_init() typical object creation function.
As result we can replace it with cpu_generic_init()
which does the same job, reducing code duplication a bit.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Thomas Huth <huth@tuxfamily.org>
Acked-by: Laurent Vivier <laurent@vivier.eu>
---
 target/m68k/cpu.h    |  3 +--
 hw/m68k/an5206.c     |  2 +-
 hw/m68k/mcf5208.c    |  2 +-
 target/m68k/cpu.c    |  2 ++
 target/m68k/helper.c | 20 --------------------
 5 files changed, 5 insertions(+), 24 deletions(-)

diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
index 38a7e11..d936547 100644
--- a/target/m68k/cpu.h
+++ b/target/m68k/cpu.h
@@ -163,7 +163,6 @@ int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 
 void m68k_tcg_init(void);
 void m68k_cpu_init_gdb(M68kCPU *cpu);
-M68kCPU *cpu_m68k_init(const char *cpu_model);
 /* you can call this signal handler from your SIGBUS and SIGSEGV
    signal handlers to inform the virtual CPU of exceptions. non zero
    is returned if the signal was handled by the virtual CPU.  */
@@ -322,7 +321,7 @@ void register_m68k_insns (CPUM68KState *env);
 #define TARGET_PHYS_ADDR_SPACE_BITS 32
 #define TARGET_VIRT_ADDR_SPACE_BITS 32
 
-#define cpu_init(cpu_model) CPU(cpu_m68k_init(cpu_model))
+#define cpu_init(cpu_model) cpu_generic_init(TYPE_M68K_CPU, cpu_model)
 
 #define cpu_signal_handler cpu_m68k_signal_handler
 #define cpu_list m68k_cpu_list
diff --git a/hw/m68k/an5206.c b/hw/m68k/an5206.c
index c762441..7b9b15d 100644
--- a/hw/m68k/an5206.c
+++ b/hw/m68k/an5206.c
@@ -42,7 +42,7 @@ static void an5206_init(MachineState *machine)
     if (!cpu_model) {
         cpu_model = "m5206";
     }
-    cpu = cpu_m68k_init(cpu_model);
+    cpu = M68K_CPU(cpu_generic_init(TYPE_M68K_CPU, cpu_model));
     if (!cpu) {
         error_report("Unable to find m68k CPU definition");
         exit(1);
diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c
index f4b1387..1a0f180 100644
--- a/hw/m68k/mcf5208.c
+++ b/hw/m68k/mcf5208.c
@@ -232,7 +232,7 @@ static void mcf5208evb_init(MachineState *machine)
     if (!cpu_model) {
         cpu_model = "m5208";
     }
-    cpu = cpu_m68k_init(cpu_model);
+    cpu = M68K_CPU(cpu_generic_init(TYPE_M68K_CPU, cpu_model));
     if (!cpu) {
         fprintf(stderr, "Unable to find m68k CPU definition\n");
         exit(1);
diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
index a14b6dd..55bf24b 100644
--- a/target/m68k/cpu.c
+++ b/target/m68k/cpu.c
@@ -230,6 +230,8 @@ static void m68k_cpu_realizefn(DeviceState *dev, Error **errp)
     M68kCPUClass *mcc = M68K_CPU_GET_CLASS(dev);
     Error *local_err = NULL;
 
+    register_m68k_insns(&cpu->env);
+
     cpu_exec_realizefn(cs, &local_err);
     if (local_err != NULL) {
         error_propagate(errp, local_err);
diff --git a/target/m68k/helper.c b/target/m68k/helper.c
index caae291..7e50ff5 100644
--- a/target/m68k/helper.c
+++ b/target/m68k/helper.c
@@ -156,26 +156,6 @@ static int m68k_fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n)
     return 0;
 }
 
-M68kCPU *cpu_m68k_init(const char *cpu_model)
-{
-    M68kCPU *cpu;
-    CPUM68KState *env;
-    ObjectClass *oc;
-
-    oc = cpu_class_by_name(TYPE_M68K_CPU, cpu_model);
-    if (oc == NULL) {
-        return NULL;
-    }
-    cpu = M68K_CPU(object_new(object_class_get_name(oc)));
-    env = &cpu->env;
-
-    register_m68k_insns(env);
-
-    object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
-
-    return cpu;
-}
-
 void m68k_cpu_init_gdb(M68kCPU *cpu)
 {
     CPUState *cs = CPU(cpu);
-- 
2.7.4

  parent reply	other threads:[~2017-08-18 10:09 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-18 10:08 [Qemu-devel] [PATCH for-2.11 00/27] complete cpu QOMification and remove cpu_FOO_init() helpers Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 01/27] sparc: convert cpu models to SPARC cpu subclasses Igor Mammedov
2017-08-18 19:00   ` Philippe Mathieu-Daudé
2017-08-21 10:55     ` Igor Mammedov
2017-08-23  1:12       ` Philippe Mathieu-Daudé
2017-08-24  2:40         ` Philippe Mathieu-Daudé
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 02/27] sparc: embed sparc_def_t into CPUSPARCState Igor Mammedov
2017-08-24  2:45   ` Philippe Mathieu-Daudé
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 03/27] sparc: convert cpu features to qdev properties Igor Mammedov
2017-08-18 18:24   ` Eduardo Habkost
2017-08-21 11:03     ` Igor Mammedov
2017-08-23 13:07       ` Eduardo Habkost
2017-08-23 14:17         ` Igor Mammedov
2017-08-24 13:32   ` Philippe Mathieu-Daudé
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 04/27] sparc: move adhoc CPUSPARCState initialization to realize time Igor Mammedov
2017-08-24  2:47   ` Philippe Mathieu-Daudé
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 05/27] target-i386: cpu: convert plus/minus properties to global properties Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 06/27] x86: extract legacy cpu features format parser Igor Mammedov
2017-08-18 18:08   ` Eduardo Habkost
2017-08-21 11:06     ` Igor Mammedov
2017-08-23 14:34   ` Eduardo Habkost
2017-08-23 16:29     ` Igor Mammedov
2017-08-23 16:46       ` Eduardo Habkost
2017-08-23 17:37         ` Igor Mammedov
2017-08-23 17:58           ` Eduardo Habkost
2017-08-24  9:18             ` Igor Mammedov
2017-08-24 13:43               ` Igor Mammedov
2017-08-24 13:45               ` Eduardo Habkost
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 07/27] sparc: replace custom cpu feature parsing with cpu_legacy_parse_featurestr() Igor Mammedov
2017-08-24 13:27   ` Philippe Mathieu-Daudé
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 08/27] sparc: replace cpu_sparc_init() with cpu_generic_init() Igor Mammedov
2017-08-18 19:57   ` Philippe Mathieu-Daudé
2017-08-21 11:11     ` Igor Mammedov
2017-08-24  2:51       ` Philippe Mathieu-Daudé
2017-08-24  2:49   ` Philippe Mathieu-Daudé
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 09/27] s390x: replace cpu_s390x_init() " Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 10/27] alpha: replace cpu_alpha_init() " Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 11/27] hppa: replace cpu_hppa_init() " Igor Mammedov
2017-08-18 10:08 ` Igor Mammedov [this message]
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 13/27] microblaze: replace cpu_mb_init() " Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 14/27] nios2: replace cpu_nios2_init() " Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 15/27] tilegx: replace cpu_tilegx_init() " Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 16/27] xtensa: replace cpu_xtensa_init() " Igor Mammedov
2017-08-24 13:21   ` Philippe Mathieu-Daudé
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 17/27] tricore: replace cpu_tricore_init() " Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 18/27] sh4: replace cpu_sh4_init() " Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 19/27] arm: replace cpu_arm_init() " Igor Mammedov
2017-08-24 13:26   ` Philippe Mathieu-Daudé
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 20/27] cris: replace cpu_cris_init() " Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 21/27] x86: replace cpu_x86_init() " Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 22/27] lm32: replace cpu_lm32_init() " Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 23/27] moxie: replace cpu_moxie_init() " Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 24/27] openrisc: replace cpu_openrisc_init() " Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 25/27] unicore32: replace uc32_cpu_init() " Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 26/27] ppc: replace cpu_ppc_init() " Igor Mammedov
2017-08-18 10:08 ` [Qemu-devel] [PATCH for-2.11 27/27] fix build failure in nbd_read_reply_entry() Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1503050939-227939-13-git-send-email-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.