1 #include "qemu/osdep.h"
2 #include "qemu-common.h"
4 #include "exec/exec-all.h"
7 #include "qemu/timer.h"
10 #include "exec/exec-all.h"
11 #include "migration/cpu.h"
12 #include "exec/exec-all.h"
15 static const VMStateDescription vmstate_cpu_timer
= {
18 .minimum_version_id
= 1,
19 .minimum_version_id_old
= 1,
20 .fields
= (VMStateField
[]) {
21 VMSTATE_UINT32(frequency
, CPUTimer
),
22 VMSTATE_UINT32(disabled
, CPUTimer
),
23 VMSTATE_UINT64(disabled_mask
, CPUTimer
),
24 VMSTATE_UINT32(npt
, CPUTimer
),
25 VMSTATE_UINT64(npt_mask
, CPUTimer
),
26 VMSTATE_INT64(clock_offset
, CPUTimer
),
27 VMSTATE_TIMER_PTR(qtimer
, CPUTimer
),
32 #define VMSTATE_CPU_TIMER(_f, _s) \
33 VMSTATE_STRUCT_POINTER(_f, _s, vmstate_cpu_timer, CPUTimer)
35 static const VMStateDescription vmstate_trap_state
= {
38 .minimum_version_id
= 1,
39 .minimum_version_id_old
= 1,
40 .fields
= (VMStateField
[]) {
41 VMSTATE_UINT64(tpc
, trap_state
),
42 VMSTATE_UINT64(tnpc
, trap_state
),
43 VMSTATE_UINT64(tstate
, trap_state
),
44 VMSTATE_UINT32(tt
, trap_state
),
49 static const VMStateDescription vmstate_tlb_entry
= {
52 .minimum_version_id
= 1,
53 .minimum_version_id_old
= 1,
54 .fields
= (VMStateField
[]) {
55 VMSTATE_UINT64(tag
, SparcTLBEntry
),
56 VMSTATE_UINT64(tte
, SparcTLBEntry
),
62 static int get_psr(QEMUFile
*f
, void *opaque
, size_t size
)
64 SPARCCPU
*cpu
= opaque
;
65 CPUSPARCState
*env
= &cpu
->env
;
66 uint32_t val
= qemu_get_be32(f
);
68 /* needed to ensure that the wrapping registers are correctly updated */
70 cpu_put_psr_raw(env
, val
);
75 static void put_psr(QEMUFile
*f
, void *opaque
, size_t size
)
77 SPARCCPU
*cpu
= opaque
;
78 CPUSPARCState
*env
= &cpu
->env
;
81 val
= cpu_get_psr(env
);
83 qemu_put_be32(f
, val
);
86 static const VMStateInfo vmstate_psr
= {
92 static void cpu_pre_save(void *opaque
)
94 SPARCCPU
*cpu
= opaque
;
95 CPUSPARCState
*env
= &cpu
->env
;
97 /* if env->cwp == env->nwindows - 1, this will set the ins of the last
98 * window as the outs of the first window
100 cpu_set_cwp(env
, env
->cwp
);
103 /* 32-bit SPARC retains migration compatibility with older versions
104 * of QEMU; 64-bit SPARC has had a migration break since then, so the
105 * versions are different.
107 #ifndef TARGET_SPARC64
108 #define SPARC_VMSTATE_VER 7
110 #define SPARC_VMSTATE_VER 9
113 const VMStateDescription vmstate_sparc_cpu
= {
115 .version_id
= SPARC_VMSTATE_VER
,
116 .minimum_version_id
= SPARC_VMSTATE_VER
,
117 .minimum_version_id_old
= SPARC_VMSTATE_VER
,
118 .pre_save
= cpu_pre_save
,
119 .fields
= (VMStateField
[]) {
120 VMSTATE_UINTTL_ARRAY(env
.gregs
, SPARCCPU
, 8),
121 VMSTATE_UINT32(env
.nwindows
, SPARCCPU
),
122 VMSTATE_VARRAY_MULTIPLY(env
.regbase
, SPARCCPU
, env
.nwindows
, 16,
123 vmstate_info_uinttl
, target_ulong
),
124 VMSTATE_CPUDOUBLE_ARRAY(env
.fpr
, SPARCCPU
, TARGET_DPREGS
),
125 VMSTATE_UINTTL(env
.pc
, SPARCCPU
),
126 VMSTATE_UINTTL(env
.npc
, SPARCCPU
),
127 VMSTATE_UINTTL(env
.y
, SPARCCPU
),
132 .size
= sizeof(uint32_t),
133 .info
= &vmstate_psr
,
137 VMSTATE_UINTTL(env
.fsr
, SPARCCPU
),
138 VMSTATE_UINTTL(env
.tbr
, SPARCCPU
),
139 VMSTATE_INT32(env
.interrupt_index
, SPARCCPU
),
140 VMSTATE_UINT32(env
.pil_in
, SPARCCPU
),
141 #ifndef TARGET_SPARC64
143 VMSTATE_UINT32(env
.wim
, SPARCCPU
),
144 VMSTATE_UINT32_ARRAY(env
.mmuregs
, SPARCCPU
, 32),
145 VMSTATE_UINT64_ARRAY(env
.mxccdata
, SPARCCPU
, 4),
146 VMSTATE_UINT64_ARRAY(env
.mxccregs
, SPARCCPU
, 8),
147 VMSTATE_UINT32(env
.mmubpctrv
, SPARCCPU
),
148 VMSTATE_UINT32(env
.mmubpctrc
, SPARCCPU
),
149 VMSTATE_UINT32(env
.mmubpctrs
, SPARCCPU
),
150 VMSTATE_UINT64(env
.mmubpaction
, SPARCCPU
),
151 VMSTATE_UINT64_ARRAY(env
.mmubpregs
, SPARCCPU
, 4),
153 VMSTATE_UINT64(env
.lsu
, SPARCCPU
),
154 VMSTATE_UINT64_ARRAY(env
.immuregs
, SPARCCPU
, 16),
155 VMSTATE_UINT64_ARRAY(env
.dmmuregs
, SPARCCPU
, 16),
156 VMSTATE_STRUCT_ARRAY(env
.itlb
, SPARCCPU
, 64, 0,
157 vmstate_tlb_entry
, SparcTLBEntry
),
158 VMSTATE_STRUCT_ARRAY(env
.dtlb
, SPARCCPU
, 64, 0,
159 vmstate_tlb_entry
, SparcTLBEntry
),
160 VMSTATE_UINT32(env
.mmu_version
, SPARCCPU
),
161 VMSTATE_STRUCT_ARRAY(env
.ts
, SPARCCPU
, MAXTL_MAX
, 0,
162 vmstate_trap_state
, trap_state
),
163 VMSTATE_UINT32(env
.xcc
, SPARCCPU
),
164 VMSTATE_UINT32(env
.asi
, SPARCCPU
),
165 VMSTATE_UINT32(env
.pstate
, SPARCCPU
),
166 VMSTATE_UINT32(env
.tl
, SPARCCPU
),
167 VMSTATE_UINT32(env
.cansave
, SPARCCPU
),
168 VMSTATE_UINT32(env
.canrestore
, SPARCCPU
),
169 VMSTATE_UINT32(env
.otherwin
, SPARCCPU
),
170 VMSTATE_UINT32(env
.wstate
, SPARCCPU
),
171 VMSTATE_UINT32(env
.cleanwin
, SPARCCPU
),
172 VMSTATE_UINT64_ARRAY(env
.agregs
, SPARCCPU
, 8),
173 VMSTATE_UINT64_ARRAY(env
.bgregs
, SPARCCPU
, 8),
174 VMSTATE_UINT64_ARRAY(env
.igregs
, SPARCCPU
, 8),
175 VMSTATE_UINT64_ARRAY(env
.mgregs
, SPARCCPU
, 8),
176 VMSTATE_UINT64(env
.fprs
, SPARCCPU
),
177 VMSTATE_UINT64(env
.tick_cmpr
, SPARCCPU
),
178 VMSTATE_UINT64(env
.stick_cmpr
, SPARCCPU
),
179 VMSTATE_CPU_TIMER(env
.tick
, SPARCCPU
),
180 VMSTATE_CPU_TIMER(env
.stick
, SPARCCPU
),
181 VMSTATE_UINT64(env
.gsr
, SPARCCPU
),
182 VMSTATE_UINT32(env
.gl
, SPARCCPU
),
183 VMSTATE_UINT64(env
.hpstate
, SPARCCPU
),
184 VMSTATE_UINT64_ARRAY(env
.htstate
, SPARCCPU
, MAXTL_MAX
),
185 VMSTATE_UINT64(env
.hintp
, SPARCCPU
),
186 VMSTATE_UINT64(env
.htba
, SPARCCPU
),
187 VMSTATE_UINT64(env
.hver
, SPARCCPU
),
188 VMSTATE_UINT64(env
.hstick_cmpr
, SPARCCPU
),
189 VMSTATE_UINT64(env
.ssr
, SPARCCPU
),
190 VMSTATE_CPU_TIMER(env
.hstick
, SPARCCPU
),
191 /* On SPARC32 env.psrpil and env.cwp are migrated as part of the PSR */
192 VMSTATE_UINT32(env
.psrpil
, SPARCCPU
),
193 VMSTATE_UINT32(env
.cwp
, SPARCCPU
),
195 VMSTATE_END_OF_LIST()