summaryrefslogtreecommitdiff
path: root/target-s390x/cpu.c
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2012-04-02 13:56:29 +0200
committerAndreas Färber <afaerber@suse.de>2012-04-04 17:35:31 +0200
commit8f22e0df803697c11e8b10c90cc2e67df6e42884 (patch)
tree184b596095a127af1b6934bcfd4a63d4d8056c8c /target-s390x/cpu.c
parent1ac1a7499bcb44174735780e0bd0421a1ac7a323 (diff)
downloadqemu-8f22e0df803697c11e8b10c90cc2e67df6e42884.tar.gz
qemu-8f22e0df803697c11e8b10c90cc2e67df6e42884.tar.bz2
qemu-8f22e0df803697c11e8b10c90cc2e67df6e42884.zip
target-s390x: QOM'ify CPU init
Move code from cpu_s390x_init() into an initfn. Signed-off-by: Andreas Färber <afaerber@suse.de> Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Diffstat (limited to 'target-s390x/cpu.c')
-rw-r--r--target-s390x/cpu.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index cae0b1894d..72ec34950b 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);
}
+static void s390_cpu_initfn(Object *obj)
+{
+ S390CPU *cpu = S390_CPU(obj);
+ CPUS390XState *env = &cpu->env;
+ static int cpu_num = 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 = TOD_UNIX_EPOCH +
+ (time2tod(mktimegm(&tm)) * 1000000000ULL);
+ env->tod_basetime = 0;
+ env->tod_timer = qemu_new_timer_ns(vm_clock, s390x_tod_timer, env);
+ env->cpu_timer = qemu_new_timer_ns(vm_clock, s390x_cpu_timer, env);
+#endif
+ env->cpu_num = cpu_num++;
+ env->ext_index = -1;
+
+ cpu_reset(CPU(cpu));
+}
+
static void s390_cpu_class_init(ObjectClass *oc, void *data)
{
S390CPUClass *scc = S390_CPU_CLASS(oc);
@@ -58,6 +82,7 @@ static const TypeInfo s390_cpu_type_info = {
.name = TYPE_S390_CPU,
.parent = TYPE_CPU,
.instance_size = sizeof(S390CPU),
+ .instance_init = s390_cpu_initfn,
.abstract = false,
.class_size = sizeof(S390CPUClass),
.class_init = s390_cpu_class_init,