From patchwork Fri Apr 6 16:17:10 2012 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: 151211 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 5B520B7097 for ; Sat, 7 Apr 2012 02:40:18 +1000 (EST) Received: from localhost ([::1]:45638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SGBs6-0003It-Nx for incoming@patchwork.ozlabs.org; Fri, 06 Apr 2012 12:18:46 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40699) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SGBr8-0000rC-2g for qemu-devel@nongnu.org; Fri, 06 Apr 2012 12:17:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SGBr5-0000U9-S8 for qemu-devel@nongnu.org; Fri, 06 Apr 2012 12:17:45 -0400 Received: from cantor2.suse.de ([195.135.220.15]:57529 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SGBr5-0000TM-Dj; Fri, 06 Apr 2012 12:17:43 -0400 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 12253A0E5F; Fri, 6 Apr 2012 18:17:42 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Fri, 6 Apr 2012 18:17:10 +0200 Message-Id: <1333729032-24441-5-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1333729032-24441-1-git-send-email-afaerber@suse.de> References: <1333729032-24441-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: Scott Wood , Alexander Graf , qemu-ppc@nongnu.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= , David Gibson Subject: [Qemu-devel] [PATCH v2 3/5] target-ppc: QOM'ify CPU init 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 Move code from cpu_ppc_init() into an initfn. Signed-off-by: Andreas Färber Acked-by: David Gibson --- target-ppc/helper.c | 10 +--------- target-ppc/translate_init.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/target-ppc/helper.c b/target-ppc/helper.c index fa9494b..f2994ca 100644 --- a/target-ppc/helper.c +++ b/target-ppc/helper.c @@ -3196,19 +3196,11 @@ CPUPPCState *cpu_ppc_init (const char *cpu_model) cpu = POWERPC_CPU(object_new(TYPE_POWERPC_CPU)); env = &cpu->env; - cpu_exec_init(env); + if (tcg_enabled()) { ppc_translate_init(); } - /* Adjust cpu index for SMT */ -#if !defined(CONFIG_USER_ONLY) - if (kvm_enabled()) { - int smt = kvmppc_smt_threads(); - env->cpu_index = (env->cpu_index / smp_threads)*smt - + (env->cpu_index % smp_threads); - } -#endif /* !CONFIG_USER_ONLY */ env->cpu_model_str = cpu_model; cpu_ppc_register_internal(env, def); diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index 24817ef..860a226 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -25,6 +25,7 @@ #include "dis-asm.h" #include "gdbstub.h" +#include "cpus.h" #include #include "kvm_ppc.h" @@ -10198,6 +10199,24 @@ static void ppc_cpu_reset(CPUState *s) cpu_state_reset(env); } +static void ppc_cpu_initfn(Object *obj) +{ + PowerPCCPU *cpu = POWERPC_CPU(obj); + CPUPPCState *env = &cpu->env; + + cpu_exec_init(env); + + /* Adjust cpu index for SMT */ +#if !defined(CONFIG_USER_ONLY) + if (kvm_enabled()) { + int smt = kvmppc_smt_threads(); + + env->cpu_index = (env->cpu_index / smp_threads) * smt + + (env->cpu_index % smp_threads); + } +#endif /* !CONFIG_USER_ONLY */ +} + static void ppc_cpu_class_init(ObjectClass *oc, void *data) { PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); @@ -10211,6 +10230,7 @@ static const TypeInfo ppc_cpu_type_info = { .name = TYPE_POWERPC_CPU, .parent = TYPE_CPU, .instance_size = sizeof(PowerPCCPU), + .instance_init = ppc_cpu_initfn, .abstract = false, .class_size = sizeof(PowerPCCPUClass), .class_init = ppc_cpu_class_init,