]> git.proxmox.com Git - mirror_qemu.git/blob - target-s390x/cpu.c
S390: Enable -cpu help and QMP query-cpu-definitions
[mirror_qemu.git] / target-s390x / cpu.c
1 /*
2 * QEMU S/390 CPU
3 *
4 * Copyright (c) 2009 Ulrich Hecht
5 * Copyright (c) 2011 Alexander Graf
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
23 #include "cpu.h"
24 #include "qemu-common.h"
25 #include "qemu/timer.h"
26 #ifndef CONFIG_USER_ONLY
27 #include "sysemu/arch_init.h"
28 #endif
29
30 /* generate CPU information for cpu -? */
31 void s390_cpu_list(FILE *f, fprintf_function cpu_fprintf)
32 {
33 #ifdef CONFIG_KVM
34 (*cpu_fprintf)(f, "s390 %16s\n", "host");
35 #endif
36 }
37
38 #ifndef CONFIG_USER_ONLY
39 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
40 {
41 CpuDefinitionInfoList *entry;
42 CpuDefinitionInfo *info;
43
44 info = g_malloc0(sizeof(*info));
45 info->name = g_strdup("host");
46
47 entry = g_malloc0(sizeof(*entry));
48 entry->value = info;
49
50 return entry;
51 }
52 #endif
53
54 /* CPUClass::reset() */
55 static void s390_cpu_reset(CPUState *s)
56 {
57 S390CPU *cpu = S390_CPU(s);
58 S390CPUClass *scc = S390_CPU_GET_CLASS(cpu);
59 CPUS390XState *env = &cpu->env;
60
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);
64 }
65
66 scc->parent_reset(s);
67
68 memset(env, 0, offsetof(CPUS390XState, breakpoints));
69 /* FIXME: reset vector? */
70 tlb_flush(env, 1);
71 s390_add_running_cpu(env);
72 }
73
74 static void s390_cpu_initfn(Object *obj)
75 {
76 S390CPU *cpu = S390_CPU(obj);
77 CPUS390XState *env = &cpu->env;
78 static int cpu_num = 0;
79 #if !defined(CONFIG_USER_ONLY)
80 struct tm tm;
81 #endif
82
83 cpu_exec_init(env);
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);
91 #endif
92 env->cpu_num = cpu_num++;
93 env->ext_index = -1;
94
95 cpu_reset(CPU(cpu));
96 }
97
98 static void s390_cpu_class_init(ObjectClass *oc, void *data)
99 {
100 S390CPUClass *scc = S390_CPU_CLASS(oc);
101 CPUClass *cc = CPU_CLASS(scc);
102
103 scc->parent_reset = cc->reset;
104 cc->reset = s390_cpu_reset;
105 }
106
107 static const TypeInfo s390_cpu_type_info = {
108 .name = TYPE_S390_CPU,
109 .parent = TYPE_CPU,
110 .instance_size = sizeof(S390CPU),
111 .instance_init = s390_cpu_initfn,
112 .abstract = false,
113 .class_size = sizeof(S390CPUClass),
114 .class_init = s390_cpu_class_init,
115 };
116
117 static void s390_cpu_register_types(void)
118 {
119 type_register_static(&s390_cpu_type_info);
120 }
121
122 type_init(s390_cpu_register_types)