4 * Copyright (c) 2009 Ulrich Hecht
5 * Copyright (c) 2011 Alexander Graf
6 * Copyright (c) 2012 SUSE LINUX Products GmbH
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.
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.
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>
24 #include "qemu-common.h"
25 #include "qemu/timer.h"
26 #ifndef CONFIG_USER_ONLY
27 #include "sysemu/arch_init.h"
30 /* generate CPU information for cpu -? */
31 void s390_cpu_list(FILE *f
, fprintf_function cpu_fprintf
)
34 (*cpu_fprintf
)(f
, "s390 %16s\n", "host");
38 #ifndef CONFIG_USER_ONLY
39 CpuDefinitionInfoList
*arch_query_cpu_definitions(Error
**errp
)
41 CpuDefinitionInfoList
*entry
;
42 CpuDefinitionInfo
*info
;
44 info
= g_malloc0(sizeof(*info
));
45 info
->name
= g_strdup("host");
47 entry
= g_malloc0(sizeof(*entry
));
54 /* CPUClass::reset() */
55 static void s390_cpu_reset(CPUState
*s
)
57 S390CPU
*cpu
= S390_CPU(s
);
58 S390CPUClass
*scc
= S390_CPU_GET_CLASS(cpu
);
59 CPUS390XState
*env
= &cpu
->env
;
61 if (qemu_loglevel_mask(CPU_LOG_RESET
)) {
62 qemu_log("CPU Reset (CPU %d)\n", s
->cpu_index
);
63 log_cpu_state(env
, 0);
68 memset(env
, 0, offsetof(CPUS390XState
, breakpoints
));
69 /* FIXME: reset vector? */
71 s390_add_running_cpu(env
);
74 static void s390_cpu_initfn(Object
*obj
)
76 S390CPU
*cpu
= S390_CPU(obj
);
77 CPUS390XState
*env
= &cpu
->env
;
78 static int cpu_num
= 0;
79 #if !defined(CONFIG_USER_ONLY)
84 #if !defined(CONFIG_USER_ONLY)
85 qemu_get_timedate(&tm
, 0);
86 env
->tod_offset
= TOD_UNIX_EPOCH
+
87 (time2tod(mktimegm(&tm
)) * 1000000000ULL);
88 env
->tod_basetime
= 0;
89 env
->tod_timer
= qemu_new_timer_ns(vm_clock
, s390x_tod_timer
, cpu
);
90 env
->cpu_timer
= qemu_new_timer_ns(vm_clock
, s390x_cpu_timer
, cpu
);
92 env
->cpu_num
= cpu_num
++;
98 static void s390_cpu_class_init(ObjectClass
*oc
, void *data
)
100 S390CPUClass
*scc
= S390_CPU_CLASS(oc
);
101 CPUClass
*cc
= CPU_CLASS(scc
);
103 scc
->parent_reset
= cc
->reset
;
104 cc
->reset
= s390_cpu_reset
;
107 static const TypeInfo s390_cpu_type_info
= {
108 .name
= TYPE_S390_CPU
,
110 .instance_size
= sizeof(S390CPU
),
111 .instance_init
= s390_cpu_initfn
,
113 .class_size
= sizeof(S390CPUClass
),
114 .class_init
= s390_cpu_class_init
,
117 static void s390_cpu_register_types(void)
119 type_register_static(&s390_cpu_type_info
);
122 type_init(s390_cpu_register_types
)