From patchwork Sun Jan 20 07:22:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 213932 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 DC88C2C0084 for ; Sun, 20 Jan 2013 19:27:33 +1100 (EST) Received: from localhost ([::1]:39693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwpHN-0001JD-BD for incoming@patchwork.ozlabs.org; Sun, 20 Jan 2013 02:25:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwpFX-0006wJ-Ge for qemu-devel@nongnu.org; Sun, 20 Jan 2013 02:23:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TwpFV-0006eo-PP for qemu-devel@nongnu.org; Sun, 20 Jan 2013 02:23:27 -0500 Received: from cantor2.suse.de ([195.135.220.15]:45264 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwpFV-0006ea-Gn for qemu-devel@nongnu.org; Sun, 20 Jan 2013 02:23:25 -0500 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 0E109A3DDF; Sun, 20 Jan 2013 08:23:25 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Sun, 20 Jan 2013 08:22:44 +0100 Message-Id: <1358666571-1737-22-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1358666571-1737-1-git-send-email-afaerber@suse.de> References: <1358666571-1737-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: "Edgar E. Iglesias" , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [RFC qom-cpu v2 21/28] target-microblaze: Move TCG initialization to MicroBlazeCPU initfn 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 Split off TCG initialization from cpu_mb_init() into mb_tcg_init() to call it from the initfn. Ensures that a QOM-created MicroBlazeCPU is usable. Signed-off-by: Andreas Färber --- target-microblaze/cpu.c | 6 ++++++ target-microblaze/cpu.h | 1 + target-microblaze/translate.c | 13 +++++-------- 3 Dateien geändert, 12 Zeilen hinzugefügt(+), 8 Zeilen entfernt(-) diff --git a/target-microblaze/cpu.c b/target-microblaze/cpu.c index d4d197d..473bd70 100644 --- a/target-microblaze/cpu.c +++ b/target-microblaze/cpu.c @@ -99,10 +99,16 @@ static void mb_cpu_initfn(Object *obj) { MicroBlazeCPU *cpu = MICROBLAZE_CPU(obj); CPUMBState *env = &cpu->env; + static bool tcg_initialized; cpu_exec_init(env); set_float_rounding_mode(float_round_nearest_even, &env->fp_status); + + if (tcg_enabled() && !tcg_initialized) { + tcg_initialized = true; + mb_tcg_init(); + } } static void mb_cpu_class_init(ObjectClass *oc, void *data) diff --git a/target-microblaze/cpu.h b/target-microblaze/cpu.h index 5621068..c66193f 100644 --- a/target-microblaze/cpu.h +++ b/target-microblaze/cpu.h @@ -272,6 +272,7 @@ struct CPUMBState { #include "cpu-qom.h" +void mb_tcg_init(void); MicroBlazeCPU *cpu_mb_init(const char *cpu_model); int cpu_mb_exec(CPUMBState *s); void do_interrupt(CPUMBState *env); diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c index a84856b..12ea820 100644 --- a/target-microblaze/translate.c +++ b/target-microblaze/translate.c @@ -1965,18 +1965,17 @@ void cpu_dump_state (CPUMBState *env, FILE *f, fprintf_function cpu_fprintf, MicroBlazeCPU *cpu_mb_init(const char *cpu_model) { MicroBlazeCPU *cpu; - static int tcg_initialized = 0; - int i; cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU)); object_property_set_bool(OBJECT(cpu), true, "realized", NULL); - if (tcg_initialized) { - return cpu; - } + return cpu; +} - tcg_initialized = 1; +void mb_tcg_init(void) +{ + int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); @@ -2007,8 +2006,6 @@ MicroBlazeCPU *cpu_mb_init(const char *cpu_model) } #define GEN_HELPER 2 #include "helper.h" - - return cpu; } void restore_state_to_opc(CPUMBState *env, TranslationBlock *tb, int pc_pos)