qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [RFC 16/20] target-m68k: move final steps of cpu_m68k_init() to realize function
Date: Tue, 18 Dec 2012 18:04:09 -0200	[thread overview]
Message-ID: <1355861053-11460-17-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1355861053-11460-1-git-send-email-ehabkost@redhat.com>

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target-m68k/cpu.c    | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 target-m68k/helper.c | 47 +----------------------------------------------
 2 files changed, 52 insertions(+), 47 deletions(-)

diff --git a/target-m68k/cpu.c b/target-m68k/cpu.c
index 3e70bb0..2e8d60e 100644
--- a/target-m68k/cpu.c
+++ b/target-m68k/cpu.c
@@ -20,7 +20,7 @@
 
 #include "cpu.h"
 #include "qemu-common.h"
-
+#include "gdbstub.h"
 
 static void m68k_set_feature(CPUM68KState *env, int feature)
 {
@@ -127,6 +127,55 @@ static void m68k_cpu_initfn(Object *obj)
     cpu_exec_init(env);
 }
 
+static int fpu_gdb_get_reg(CPUM68KState *env, uint8_t *mem_buf, int n)
+{
+    if (n < 8) {
+        stfq_p(mem_buf, env->fregs[n]);
+        return 8;
+    }
+    if (n < 11) {
+        /* FP control registers (not implemented)  */
+        memset(mem_buf, 0, 4);
+        return 4;
+    }
+    return 0;
+}
+
+static int fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n)
+{
+    if (n < 8) {
+        env->fregs[n] = ldfq_p(mem_buf);
+        return 8;
+    }
+    if (n < 11) {
+        /* FP control registers (not implemented)  */
+        return 4;
+    }
+    return 0;
+}
+
+static void cpu_m68k_realize(CPUState *cobj, Error **errp)
+{
+    M68kCPU *cpu = M68K_CPU(cobj);
+    CPUM68KState *env = &cpu->env;
+    static int inited;
+
+    if (!inited) {
+        inited = 1;
+        m68k_tcg_init();
+    }
+
+    register_m68k_insns(env);
+    if (m68k_feature(env, M68K_FEATURE_CF_FPU)) {
+        gdb_register_coprocessor(env, fpu_gdb_get_reg, fpu_gdb_set_reg,
+                                 11, "cf-fp.xml", 18);
+    }
+    /* TODO: Add [E]MAC registers.  */
+
+    cpu_reset(cobj);
+    qemu_init_vcpu(env);
+}
+
 static void m68k_cpu_class_init(ObjectClass *c, void *data)
 {
     M68kCPUClass *mcc = M68K_CPU_CLASS(c);
@@ -134,6 +183,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data)
 
     mcc->parent_reset = cc->reset;
     cc->reset = m68k_cpu_reset;
+    cc->realize = cpu_m68k_realize;
 }
 
 static void register_cpu_type(const M68kCPUInfo *info)
diff --git a/target-m68k/helper.c b/target-m68k/helper.c
index 4d88bb0..f122706 100644
--- a/target-m68k/helper.c
+++ b/target-m68k/helper.c
@@ -19,7 +19,6 @@
  */
 
 #include "cpu.h"
-#include "gdbstub.h"
 
 #include "helpers.h"
 
@@ -71,61 +70,17 @@ void m68k_cpu_list(FILE *f, fprintf_function cpu_fprintf)
     g_slist_free(list);
 }
 
-static int fpu_gdb_get_reg(CPUM68KState *env, uint8_t *mem_buf, int n)
-{
-    if (n < 8) {
-        stfq_p(mem_buf, env->fregs[n]);
-        return 8;
-    }
-    if (n < 11) {
-        /* FP control registers (not implemented)  */
-        memset(mem_buf, 0, 4);
-        return 4;
-    }
-    return 0;
-}
-
-static int fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n)
-{
-    if (n < 8) {
-        env->fregs[n] = ldfq_p(mem_buf);
-        return 8;
-    }
-    if (n < 11) {
-        /* FP control registers (not implemented)  */
-        return 4;
-    }
-    return 0;
-}
-
 CPUState *cpu_m68k_init(const char *cpu_model)
 {
     M68kCPU *cpu;
-    CPUM68KState *env;
-    static int inited;
 
     if (object_class_by_name(cpu_model) == NULL) {
         return NULL;
     }
     cpu = M68K_CPU(object_new(cpu_model));
-    env = &cpu->env;
-
-    if (!inited) {
-        inited = 1;
-        m68k_tcg_init();
-    }
-
     CPU(cpu)->cpu_model_str = cpu_model;
+    cpu_realize(CPU(cpu), NULL);
 
-    register_m68k_insns(env);
-    if (m68k_feature(env, M68K_FEATURE_CF_FPU)) {
-        gdb_register_coprocessor(env, fpu_gdb_get_reg, fpu_gdb_set_reg,
-                                 11, "cf-fp.xml", 18);
-    }
-    /* TODO: Add [E]MAC registers.  */
-
-    cpu_reset(ENV_GET_CPU(env));
-    qemu_init_vcpu(env);
     return CPU(cpu);
 }
 
-- 
1.7.11.7

  parent reply	other threads:[~2012-12-18 20:02 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-18 20:03 [Qemu-devel] [RFC 00/20] generic_cpu_init() and generic_cpu_create() functions Eduardo Habkost
2012-12-18 20:03 ` [Qemu-devel] [RFC 01/20] qemu-common.h: "use" env parameter in no-op version of qemu_init_vcpu() Eduardo Habkost
2012-12-18 20:03 ` [Qemu-devel] [RFC 02/20] cpu: introduce CPU_GET_ENV macros Eduardo Habkost
2012-12-18 20:03 ` [Qemu-devel] [RFC 03/20] cpu: make cpu_init return CPUState QOM object Eduardo Habkost
2012-12-18 20:03 ` [Qemu-devel] [RFC 04/20] cpu: replace trivial old_cpu_init functions Eduardo Habkost
2012-12-18 20:03 ` [Qemu-devel] [RFC 05/20] alpha: convert cpu_init to QOM Eduardo Habkost
2012-12-18 20:03 ` [Qemu-devel] [RFC 06/20] m68k: " Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 07/20] target-unicore32: " Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 08/20] cpu: move cpu_model_str to CPUState Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 09/20] cpu: introduce cpu_realize() Eduardo Habkost
2012-12-18 23:13   ` Andreas Färber
2012-12-18 20:04 ` [Qemu-devel] [RFC 10/20] cpu: introduce generic_cpu_init() & generic_cpu_create() functions Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 11/20] target-openrisc: implement CPU realize() method Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 12/20] hw/openrisc_sim.c: coding style/indentation fix Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 13/20] target-openrisc: replace cpu_openrisc_init() with generic_cpu_init() Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 14/20] target-arm: move final steps of cpu_arm_init() to realize function Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 15/20] target-arm: replace cpu_arm_init() with generic_cpu_init() Eduardo Habkost
2012-12-18 20:04 ` Eduardo Habkost [this message]
2012-12-18 20:04 ` [Qemu-devel] [RFC 17/20] target-m68k: replace cpu_m68k_init() " Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 18/20] target-unicore32: move final steps of uc32_cpu_init() to realize function Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 19/20] target-unicore32: replace uc32_cpu_init() with generic_cpu_init() Eduardo Habkost
2012-12-18 20:04 ` [Qemu-devel] [RFC 20/20] cpu: convert cpu_copy() to QOM Eduardo Habkost
2012-12-18 22:57 ` [Qemu-devel] [RFC 00/20] generic_cpu_init() and generic_cpu_create() functions Andreas Färber
2012-12-19  0:08   ` Eduardo Habkost

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=1355861053-11460-17-git-send-email-ehabkost@redhat.com \
    --to=ehabkost@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).