From patchwork Tue Dec 18 20:04:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 207205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 06B7A2C007C for ; Wed, 19 Dec 2012 07:59:05 +1100 (EST) Received: from localhost ([::1]:33284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl3OR-0007jl-4r for incoming@patchwork.ozlabs.org; Tue, 18 Dec 2012 15:03:59 -0500 Received: from eggs.gnu.org ([208.118.235.92]:34202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl3NP-0005Sw-Ll for qemu-devel@nongnu.org; Tue, 18 Dec 2012 15:02:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tl3NH-0000ds-Om for qemu-devel@nongnu.org; Tue, 18 Dec 2012 15:02:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:8352) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl3NH-0000co-GY for qemu-devel@nongnu.org; Tue, 18 Dec 2012 15:02:47 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBIK2kFQ020302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Dec 2012 15:02:46 -0500 Received: from blackpad.lan.raisama.net (vpn1-6-125.gru2.redhat.com [10.97.6.125]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qBIK2jHj007317 for ; Tue, 18 Dec 2012 15:02:46 -0500 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id 609D3200A01; Tue, 18 Dec 2012 18:04:19 -0200 (BRST) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Tue, 18 Dec 2012 18:04:09 -0200 Message-Id: <1355861053-11460-17-git-send-email-ehabkost@redhat.com> In-Reply-To: <1355861053-11460-1-git-send-email-ehabkost@redhat.com> References: <1355861053-11460-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 16/20] target-m68k: move final steps of cpu_m68k_init() to realize function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Eduardo Habkost --- 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); }