]> git.proxmox.com Git - qemu.git/blame - target-s390x/cpu.c
cpu: Move cpu_index field to CPUState
[qemu.git] / target-s390x / cpu.c
CommitLineData
29e4bcb2
AF
1/*
2 * QEMU S/390 CPU
3 *
1ac1a749
AF
4 * Copyright (c) 2009 Ulrich Hecht
5 * Copyright (c) 2011 Alexander Graf
29e4bcb2
AF
6 * Copyright (c) 2012 SUSE LINUX Products GmbH
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, see
20 * <http://www.gnu.org/licenses/lgpl-2.1.html>
21 */
22
564b863d 23#include "cpu.h"
29e4bcb2 24#include "qemu-common.h"
1de7afc9 25#include "qemu/timer.h"
29e4bcb2
AF
26
27
1ac1a749 28/* CPUClass::reset() */
29e4bcb2
AF
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
1ac1a749 35 if (qemu_loglevel_mask(CPU_LOG_RESET)) {
55e5c285 36 qemu_log("CPU Reset (CPU %d)\n", s->cpu_index);
1ac1a749
AF
37 log_cpu_state(env, 0);
38 }
39
29e4bcb2
AF
40 scc->parent_reset(s);
41
1ac1a749
AF
42 memset(env, 0, offsetof(CPUS390XState, breakpoints));
43 /* FIXME: reset vector? */
44 tlb_flush(env, 1);
45 s390_add_running_cpu(env);
29e4bcb2
AF
46}
47
8f22e0df
AF
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;
b8ba6799
AF
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);
8f22e0df
AF
65#endif
66 env->cpu_num = cpu_num++;
67 env->ext_index = -1;
68
69 cpu_reset(CPU(cpu));
70}
71
29e4bcb2
AF
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),
8f22e0df 85 .instance_init = s390_cpu_initfn,
29e4bcb2
AF
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)