s390x/sclp: add device to the sysbus in sclp_realize
[qemu.git] / target-sparc / machine.c
blobaecbe2cedbf2f2d97c77fb84e82727a9f89f000c
1 #include "hw/hw.h"
2 #include "hw/boards.h"
3 #include "qemu/timer.h"
5 #include "cpu.h"
7 #ifdef TARGET_SPARC64
8 static const VMStateDescription vmstate_cpu_timer = {
9 .name = "cpu_timer",
10 .version_id = 1,
11 .minimum_version_id = 1,
12 .minimum_version_id_old = 1,
13 .fields = (VMStateField[]) {
14 VMSTATE_UINT32(frequency, CPUTimer),
15 VMSTATE_UINT32(disabled, CPUTimer),
16 VMSTATE_UINT64(disabled_mask, CPUTimer),
17 VMSTATE_UINT32(npt, CPUTimer),
18 VMSTATE_UINT64(npt_mask, CPUTimer),
19 VMSTATE_INT64(clock_offset, CPUTimer),
20 VMSTATE_TIMER_PTR(qtimer, CPUTimer),
21 VMSTATE_END_OF_LIST()
25 #define VMSTATE_CPU_TIMER(_f, _s) \
26 VMSTATE_STRUCT_POINTER(_f, _s, vmstate_cpu_timer, CPUTimer)
28 static const VMStateDescription vmstate_trap_state = {
29 .name = "trap_state",
30 .version_id = 1,
31 .minimum_version_id = 1,
32 .minimum_version_id_old = 1,
33 .fields = (VMStateField[]) {
34 VMSTATE_UINT64(tpc, trap_state),
35 VMSTATE_UINT64(tnpc, trap_state),
36 VMSTATE_UINT64(tstate, trap_state),
37 VMSTATE_UINT32(tt, trap_state),
38 VMSTATE_END_OF_LIST()
42 static const VMStateDescription vmstate_tlb_entry = {
43 .name = "tlb_entry",
44 .version_id = 1,
45 .minimum_version_id = 1,
46 .minimum_version_id_old = 1,
47 .fields = (VMStateField[]) {
48 VMSTATE_UINT64(tag, SparcTLBEntry),
49 VMSTATE_UINT64(tte, SparcTLBEntry),
50 VMSTATE_END_OF_LIST()
53 #endif
55 static int get_psr(QEMUFile *f, void *opaque, size_t size)
57 SPARCCPU *cpu = opaque;
58 CPUSPARCState *env = &cpu->env;
59 uint32_t val = qemu_get_be32(f);
61 /* needed to ensure that the wrapping registers are correctly updated */
62 env->cwp = 0;
63 cpu_put_psr_raw(env, val);
65 return 0;
68 static void put_psr(QEMUFile *f, void *opaque, size_t size)
70 SPARCCPU *cpu = opaque;
71 CPUSPARCState *env = &cpu->env;
72 uint32_t val;
74 val = cpu_get_psr(env);
76 qemu_put_be32(f, val);
79 static const VMStateInfo vmstate_psr = {
80 .name = "psr",
81 .get = get_psr,
82 .put = put_psr,
85 static void cpu_pre_save(void *opaque)
87 SPARCCPU *cpu = opaque;
88 CPUSPARCState *env = &cpu->env;
90 /* if env->cwp == env->nwindows - 1, this will set the ins of the last
91 * window as the outs of the first window
93 cpu_set_cwp(env, env->cwp);
96 /* 32-bit SPARC retains migration compatibility with older versions
97 * of QEMU; 64-bit SPARC has had a migration break since then, so the
98 * versions are different.
100 #ifndef TARGET_SPARC64
101 #define SPARC_VMSTATE_VER 7
102 #else
103 #define SPARC_VMSTATE_VER 9
104 #endif
106 const VMStateDescription vmstate_sparc_cpu = {
107 .name = "cpu",
108 .version_id = SPARC_VMSTATE_VER,
109 .minimum_version_id = SPARC_VMSTATE_VER,
110 .minimum_version_id_old = SPARC_VMSTATE_VER,
111 .pre_save = cpu_pre_save,
112 .fields = (VMStateField[]) {
113 VMSTATE_UINTTL_ARRAY(env.gregs, SPARCCPU, 8),
114 VMSTATE_UINT32(env.nwindows, SPARCCPU),
115 VMSTATE_VARRAY_MULTIPLY(env.regbase, SPARCCPU, env.nwindows, 16,
116 vmstate_info_uinttl, target_ulong),
117 VMSTATE_CPUDOUBLE_ARRAY(env.fpr, SPARCCPU, TARGET_DPREGS),
118 VMSTATE_UINTTL(env.pc, SPARCCPU),
119 VMSTATE_UINTTL(env.npc, SPARCCPU),
120 VMSTATE_UINTTL(env.y, SPARCCPU),
123 .name = "psr",
124 .version_id = 0,
125 .size = sizeof(uint32_t),
126 .info = &vmstate_psr,
127 .flags = VMS_SINGLE,
128 .offset = 0,
130 VMSTATE_UINTTL(env.fsr, SPARCCPU),
131 VMSTATE_UINTTL(env.tbr, SPARCCPU),
132 VMSTATE_INT32(env.interrupt_index, SPARCCPU),
133 VMSTATE_UINT32(env.pil_in, SPARCCPU),
134 #ifndef TARGET_SPARC64
135 /* MMU */
136 VMSTATE_UINT32(env.wim, SPARCCPU),
137 VMSTATE_UINT32_ARRAY(env.mmuregs, SPARCCPU, 32),
138 VMSTATE_UINT64_ARRAY(env.mxccdata, SPARCCPU, 4),
139 VMSTATE_UINT64_ARRAY(env.mxccregs, SPARCCPU, 8),
140 VMSTATE_UINT32(env.mmubpctrv, SPARCCPU),
141 VMSTATE_UINT32(env.mmubpctrc, SPARCCPU),
142 VMSTATE_UINT32(env.mmubpctrs, SPARCCPU),
143 VMSTATE_UINT64(env.mmubpaction, SPARCCPU),
144 VMSTATE_UINT64_ARRAY(env.mmubpregs, SPARCCPU, 4),
145 #else
146 VMSTATE_UINT64(env.lsu, SPARCCPU),
147 VMSTATE_UINT64_ARRAY(env.immuregs, SPARCCPU, 16),
148 VMSTATE_UINT64_ARRAY(env.dmmuregs, SPARCCPU, 16),
149 VMSTATE_STRUCT_ARRAY(env.itlb, SPARCCPU, 64, 0,
150 vmstate_tlb_entry, SparcTLBEntry),
151 VMSTATE_STRUCT_ARRAY(env.dtlb, SPARCCPU, 64, 0,
152 vmstate_tlb_entry, SparcTLBEntry),
153 VMSTATE_UINT32(env.mmu_version, SPARCCPU),
154 VMSTATE_STRUCT_ARRAY(env.ts, SPARCCPU, MAXTL_MAX, 0,
155 vmstate_trap_state, trap_state),
156 VMSTATE_UINT32(env.xcc, SPARCCPU),
157 VMSTATE_UINT32(env.asi, SPARCCPU),
158 VMSTATE_UINT32(env.pstate, SPARCCPU),
159 VMSTATE_UINT32(env.tl, SPARCCPU),
160 VMSTATE_UINT32(env.cansave, SPARCCPU),
161 VMSTATE_UINT32(env.canrestore, SPARCCPU),
162 VMSTATE_UINT32(env.otherwin, SPARCCPU),
163 VMSTATE_UINT32(env.wstate, SPARCCPU),
164 VMSTATE_UINT32(env.cleanwin, SPARCCPU),
165 VMSTATE_UINT64_ARRAY(env.agregs, SPARCCPU, 8),
166 VMSTATE_UINT64_ARRAY(env.bgregs, SPARCCPU, 8),
167 VMSTATE_UINT64_ARRAY(env.igregs, SPARCCPU, 8),
168 VMSTATE_UINT64_ARRAY(env.mgregs, SPARCCPU, 8),
169 VMSTATE_UINT64(env.fprs, SPARCCPU),
170 VMSTATE_UINT64(env.tick_cmpr, SPARCCPU),
171 VMSTATE_UINT64(env.stick_cmpr, SPARCCPU),
172 VMSTATE_CPU_TIMER(env.tick, SPARCCPU),
173 VMSTATE_CPU_TIMER(env.stick, SPARCCPU),
174 VMSTATE_UINT64(env.gsr, SPARCCPU),
175 VMSTATE_UINT32(env.gl, SPARCCPU),
176 VMSTATE_UINT64(env.hpstate, SPARCCPU),
177 VMSTATE_UINT64_ARRAY(env.htstate, SPARCCPU, MAXTL_MAX),
178 VMSTATE_UINT64(env.hintp, SPARCCPU),
179 VMSTATE_UINT64(env.htba, SPARCCPU),
180 VMSTATE_UINT64(env.hver, SPARCCPU),
181 VMSTATE_UINT64(env.hstick_cmpr, SPARCCPU),
182 VMSTATE_UINT64(env.ssr, SPARCCPU),
183 VMSTATE_CPU_TIMER(env.hstick, SPARCCPU),
184 /* On SPARC32 env.psrpil and env.cwp are migrated as part of the PSR */
185 VMSTATE_UINT32(env.psrpil, SPARCCPU),
186 VMSTATE_UINT32(env.cwp, SPARCCPU),
187 #endif
188 VMSTATE_END_OF_LIST()