From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFTsD-0005cu-Ng for qemu-devel@nongnu.org; Wed, 04 Apr 2012 13:20:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SFTs7-00009S-3d for qemu-devel@nongnu.org; Wed, 04 Apr 2012 13:19:57 -0400 Received: from cantor2.suse.de ([195.135.220.15]:57429 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFTs6-0008W2-RP for qemu-devel@nongnu.org; Wed, 04 Apr 2012 13:19:51 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 4 Apr 2012 19:19:38 +0200 Message-Id: <1333559979-3984-4-git-send-email-afaerber@suse.de> In-Reply-To: <1333559979-3984-1-git-send-email-afaerber@suse.de> References: <1333559979-3984-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 3/4] target-s390x: QOM'ify CPU init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: blauwirbel@gmail.com, Christian Borntraeger , Alexander Graf , anthony@codemonkey.ws, =?UTF-8?q?Andreas=20F=C3=A4rber?= Move code from cpu_s390x_init() into an initfn. Signed-off-by: Andreas F=C3=A4rber Tested-by: Christian Borntraeger --- target-s390x/cpu.c | 25 +++++++++++++++++++++++++ target-s390x/cpu.h | 3 +++ target-s390x/helper.c | 21 +++------------------ 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index cae0b18..72ec349 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -45,6 +45,30 @@ static void s390_cpu_reset(CPUState *s) s390_add_running_cpu(env); } =20 +static void s390_cpu_initfn(Object *obj) +{ + S390CPU *cpu =3D S390_CPU(obj); + CPUS390XState *env =3D &cpu->env; + static int cpu_num =3D 0; +#if !defined(CONFIG_USER_ONLY) + struct tm tm; +#endif + + cpu_exec_init(env); +#if !defined(CONFIG_USER_ONLY) + qemu_get_timedate(&tm, 0); + env->tod_offset =3D TOD_UNIX_EPOCH + + (time2tod(mktimegm(&tm)) * 1000000000ULL); + env->tod_basetime =3D 0; + env->tod_timer =3D qemu_new_timer_ns(vm_clock, s390x_tod_timer, env)= ; + env->cpu_timer =3D qemu_new_timer_ns(vm_clock, s390x_cpu_timer, env)= ; +#endif + env->cpu_num =3D cpu_num++; + env->ext_index =3D -1; + + cpu_reset(CPU(cpu)); +} + static void s390_cpu_class_init(ObjectClass *oc, void *data) { S390CPUClass *scc =3D S390_CPU_CLASS(oc); @@ -58,6 +82,7 @@ static const TypeInfo s390_cpu_type_info =3D { .name =3D TYPE_S390_CPU, .parent =3D TYPE_CPU, .instance_size =3D sizeof(S390CPU), + .instance_init =3D s390_cpu_initfn, .abstract =3D false, .class_size =3D sizeof(S390CPUClass), .class_init =3D s390_cpu_class_init, diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h index c6ee959..2f3f394 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -288,6 +288,9 @@ int cpu_s390x_handle_mmu_fault (CPUS390XState *env, t= arget_ulong address, int rw =20 =20 #ifndef CONFIG_USER_ONLY +void s390x_tod_timer(void *opaque); +void s390x_cpu_timer(void *opaque); + int s390_virtio_hypercall(CPUS390XState *env, uint64_t mem, uint64_t hyp= ercall); =20 #ifdef CONFIG_KVM diff --git a/target-s390x/helper.c b/target-s390x/helper.c index cd3e8f5..6233f9a 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -51,7 +51,7 @@ #endif =20 #ifndef CONFIG_USER_ONLY -static void s390x_tod_timer(void *opaque) +void s390x_tod_timer(void *opaque) { CPUS390XState *env =3D opaque; =20 @@ -59,7 +59,7 @@ static void s390x_tod_timer(void *opaque) cpu_interrupt(env, CPU_INTERRUPT_HARD); } =20 -static void s390x_cpu_timer(void *opaque) +void s390x_cpu_timer(void *opaque) { CPUS390XState *env =3D opaque; =20 @@ -72,32 +72,17 @@ CPUS390XState *cpu_s390x_init(const char *cpu_model) { S390CPU *cpu; CPUS390XState *env; -#if !defined (CONFIG_USER_ONLY) - struct tm tm; -#endif static int inited =3D 0; - static int cpu_num =3D 0; =20 cpu =3D S390_CPU(object_new(TYPE_S390_CPU)); env =3D &cpu->env; - cpu_exec_init(env); + if (tcg_enabled() && !inited) { inited =3D 1; s390x_translate_init(); } =20 -#if !defined(CONFIG_USER_ONLY) - qemu_get_timedate(&tm, 0); - env->tod_offset =3D TOD_UNIX_EPOCH + - (time2tod(mktimegm(&tm)) * 1000000000ULL); - env->tod_basetime =3D 0; - env->tod_timer =3D qemu_new_timer_ns(vm_clock, s390x_tod_timer, env)= ; - env->cpu_timer =3D qemu_new_timer_ns(vm_clock, s390x_cpu_timer, env)= ; -#endif env->cpu_model_str =3D cpu_model; - env->cpu_num =3D cpu_num++; - env->ext_index =3D -1; - cpu_reset(CPU(cpu)); qemu_init_vcpu(env); return env; } --=20 1.7.7