From patchwork Tue Dec 18 20:04:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 207208 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 318272C0089 for ; Wed, 19 Dec 2012 08:13:02 +1100 (EST) Received: from localhost ([::1]:35242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl3P8-0000Mw-Tf for incoming@patchwork.ozlabs.org; Tue, 18 Dec 2012 15:04:42 -0500 Received: from eggs.gnu.org ([208.118.235.92]:34170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl3NN-0005MH-6c for qemu-devel@nongnu.org; Tue, 18 Dec 2012 15:02:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tl3NH-0000e6-UX for qemu-devel@nongnu.org; Tue, 18 Dec 2012 15:02:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60370) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl3NH-0000dO-K9 for qemu-devel@nongnu.org; Tue, 18 Dec 2012 15:02:47 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBIK2l8L010598 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Dec 2012 15:02:47 -0500 Received: from blackpad.lan.raisama.net (vpn1-6-125.gru2.redhat.com [10.97.6.125]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBIK2kl3022787 for ; Tue, 18 Dec 2012 15:02:46 -0500 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id 8F22B2036F2; Tue, 18 Dec 2012 18:04:19 -0200 (BRST) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Tue, 18 Dec 2012 18:04:11 -0200 Message-Id: <1355861053-11460-19-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.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 18/20] target-unicore32: move final steps of uc32_cpu_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-unicore32/cpu.c | 21 +++++++++++++++++++++ target-unicore32/helper.c | 11 +---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c index 76750da..5467127 100644 --- a/target-unicore32/cpu.c +++ b/target-unicore32/cpu.c @@ -80,12 +80,33 @@ static void uc32_cpu_initfn(Object *obj) tlb_flush(env, 1); } +static void uc32_cpu_realize(CPUState *cobj, Error **errp) +{ + UniCore32CPU *cpu = UNICORE32_CPU(cobj); + CPUUniCore32State *env = &cpu->env; + static int inited; + + if (!inited) { + inited = 1; + uc32_translate_init(); + } + + qemu_init_vcpu(env); +} + +static void uc32_class_init(ObjectClass *oc, void *data) +{ + CPUClass *cc = CPU_CLASS(oc); + cc->realize = uc32_cpu_realize; +} + static void uc32_register_cpu_type(const UniCore32CPUInfo *info) { TypeInfo type_info = { .name = info->name, .parent = TYPE_UNICORE32_CPU, .instance_init = info->instance_init, + .class_init = uc32_class_init, }; type_register_static(&type_info); diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c index dc7b0b3..927e591 100644 --- a/target-unicore32/helper.c +++ b/target-unicore32/helper.c @@ -26,21 +26,12 @@ CPUState *uc32_cpu_init(const char *cpu_model) { UniCore32CPU *cpu; - CPUUniCore32State *env; - static int inited = 1; if (object_class_by_name(cpu_model) == NULL) { return NULL; } cpu = UNICORE32_CPU(object_new(cpu_model)); - env = &cpu->env; - - if (inited) { - inited = 0; - uc32_translate_init(); - } - - qemu_init_vcpu(env); + cpu_realize(CPU(cpu), NULL); return CPU(cpu); }