1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#include "cpu.h"
24#include "qemu-common.h"
25#include "qemu-timer.h"
26
27
28
29static void s390_cpu_reset(CPUState *s)
30{
31 S390CPU *cpu = S390_CPU(s);
32 S390CPUClass *scc = S390_CPU_GET_CLASS(cpu);
33 CPUS390XState *env = &cpu->env;
34
35 if (qemu_loglevel_mask(CPU_LOG_RESET)) {
36 qemu_log("CPU Reset (CPU %d)\n", env->cpu_index);
37 log_cpu_state(env, 0);
38 }
39
40 scc->parent_reset(s);
41
42 memset(env, 0, offsetof(CPUS390XState, breakpoints));
43
44 tlb_flush(env, 1);
45 s390_add_running_cpu(env);
46}
47
48static void s390_cpu_initfn(Object *obj)
49{
50 S390CPU *cpu = S390_CPU(obj);
51 CPUS390XState *env = &cpu->env;
52 static int cpu_num = 0;
53#if !defined(CONFIG_USER_ONLY)
54 struct tm tm;
55#endif
56
57 cpu_exec_init(env);
58#if !defined(CONFIG_USER_ONLY)
59 qemu_get_timedate(&tm, 0);
60 env->tod_offset = TOD_UNIX_EPOCH +
61 (time2tod(mktimegm(&tm)) * 1000000000ULL);
62 env->tod_basetime = 0;
63 env->tod_timer = qemu_new_timer_ns(vm_clock, s390x_tod_timer, cpu);
64 env->cpu_timer = qemu_new_timer_ns(vm_clock, s390x_cpu_timer, cpu);
65#endif
66 env->cpu_num = cpu_num++;
67 env->ext_index = -1;
68
69 cpu_reset(CPU(cpu));
70}
71
72static void s390_cpu_class_init(ObjectClass *oc, void *data)
73{
74 S390CPUClass *scc = S390_CPU_CLASS(oc);
75 CPUClass *cc = CPU_CLASS(scc);
76
77 scc->parent_reset = cc->reset;
78 cc->reset = s390_cpu_reset;
79}
80
81static const TypeInfo s390_cpu_type_info = {
82 .name = TYPE_S390_CPU,
83 .parent = TYPE_CPU,
84 .instance_size = sizeof(S390CPU),
85 .instance_init = s390_cpu_initfn,
86 .abstract = false,
87 .class_size = sizeof(S390CPUClass),
88 .class_init = s390_cpu_class_init,
89};
90
91static void s390_cpu_register_types(void)
92{
93 type_register_static(&s390_cpu_type_info);
94}
95
96type_init(s390_cpu_register_types)
97