1 #include "qemu/osdep.h"
3 #include "exec/exec-all.h"
4 #include "qemu/timer.h"
6 #include "migration/cpu.h"
9 static const VMStateDescription vmstate_cpu_timer
= {
12 .minimum_version_id
= 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
),
25 #define VMSTATE_CPU_TIMER(_f, _s) \
26 VMSTATE_STRUCT_POINTER(_f, _s, vmstate_cpu_timer, CPUTimer)
28 static const VMStateDescription vmstate_trap_state
= {
31 .minimum_version_id
= 1,
32 .fields
= (VMStateField
[]) {
33 VMSTATE_UINT64(tpc
, trap_state
),
34 VMSTATE_UINT64(tnpc
, trap_state
),
35 VMSTATE_UINT64(tstate
, trap_state
),
36 VMSTATE_UINT32(tt
, trap_state
),
41 static const VMStateDescription vmstate_tlb_entry
= {
44 .minimum_version_id
= 1,
45 .fields
= (VMStateField
[]) {
46 VMSTATE_UINT64(tag
, SparcTLBEntry
),
47 VMSTATE_UINT64(tte
, SparcTLBEntry
),
53 static int get_psr(QEMUFile
*f
, void *opaque
, size_t size
,
54 const VMStateField
*field
)
56 SPARCCPU
*cpu
= opaque
;
57 CPUSPARCState
*env
= &cpu
->env
;
58 uint32_t val
= qemu_get_be32(f
);
60 /* needed to ensure that the wrapping registers are correctly updated */
62 cpu_put_psr_raw(env
, val
);
67 static int put_psr(QEMUFile
*f
, void *opaque
, size_t size
,
68 const VMStateField
*field
, JSONWriter
*vmdesc
)
70 SPARCCPU
*cpu
= opaque
;
71 CPUSPARCState
*env
= &cpu
->env
;
74 val
= cpu_get_psr(env
);
76 qemu_put_be32(f
, val
);
80 static const VMStateInfo vmstate_psr
= {
86 static int cpu_pre_save(void *opaque
)
88 SPARCCPU
*cpu
= opaque
;
89 CPUSPARCState
*env
= &cpu
->env
;
91 /* if env->cwp == env->nwindows - 1, this will set the ins of the last
92 * window as the outs of the first window
94 cpu_set_cwp(env
, env
->cwp
);
99 /* 32-bit SPARC retains migration compatibility with older versions
100 * of QEMU; 64-bit SPARC has had a migration break since then, so the
101 * versions are different.
103 #ifndef TARGET_SPARC64
104 #define SPARC_VMSTATE_VER 7
106 #define SPARC_VMSTATE_VER 9
109 const VMStateDescription vmstate_sparc_cpu
= {
111 .version_id
= SPARC_VMSTATE_VER
,
112 .minimum_version_id
= SPARC_VMSTATE_VER
,
113 .pre_save
= cpu_pre_save
,
114 .fields
= (VMStateField
[]) {
115 VMSTATE_UINTTL_ARRAY(env
.gregs
, SPARCCPU
, 8),
116 VMSTATE_UINT32(env
.nwindows
, SPARCCPU
),
117 VMSTATE_VARRAY_MULTIPLY(env
.regbase
, SPARCCPU
, env
.nwindows
, 16,
118 vmstate_info_uinttl
, target_ulong
),
119 VMSTATE_CPUDOUBLE_ARRAY(env
.fpr
, SPARCCPU
, TARGET_DPREGS
),
120 VMSTATE_UINTTL(env
.pc
, SPARCCPU
),
121 VMSTATE_UINTTL(env
.npc
, SPARCCPU
),
122 VMSTATE_UINTTL(env
.y
, SPARCCPU
),
127 .size
= sizeof(uint32_t),
128 .info
= &vmstate_psr
,
132 VMSTATE_UINTTL(env
.fsr
, SPARCCPU
),
133 VMSTATE_UINTTL(env
.tbr
, SPARCCPU
),
134 VMSTATE_INT32(env
.interrupt_index
, SPARCCPU
),
135 VMSTATE_UINT32(env
.pil_in
, SPARCCPU
),
136 #ifndef TARGET_SPARC64
138 VMSTATE_UINT32(env
.wim
, SPARCCPU
),
139 VMSTATE_UINT32_ARRAY(env
.mmuregs
, SPARCCPU
, 32),
140 VMSTATE_UINT64_ARRAY(env
.mxccdata
, SPARCCPU
, 4),
141 VMSTATE_UINT64_ARRAY(env
.mxccregs
, SPARCCPU
, 8),
142 VMSTATE_UINT32(env
.mmubpctrv
, SPARCCPU
),
143 VMSTATE_UINT32(env
.mmubpctrc
, SPARCCPU
),
144 VMSTATE_UINT32(env
.mmubpctrs
, SPARCCPU
),
145 VMSTATE_UINT64(env
.mmubpaction
, SPARCCPU
),
146 VMSTATE_UINT64_ARRAY(env
.mmubpregs
, SPARCCPU
, 4),
148 VMSTATE_UINT64(env
.lsu
, SPARCCPU
),
149 VMSTATE_UINT64_ARRAY(env
.immu
.mmuregs
, SPARCCPU
, 16),
150 VMSTATE_UINT64_ARRAY(env
.dmmu
.mmuregs
, SPARCCPU
, 16),
151 VMSTATE_STRUCT_ARRAY(env
.itlb
, SPARCCPU
, 64, 0,
152 vmstate_tlb_entry
, SparcTLBEntry
),
153 VMSTATE_STRUCT_ARRAY(env
.dtlb
, SPARCCPU
, 64, 0,
154 vmstate_tlb_entry
, SparcTLBEntry
),
155 VMSTATE_UINT32(env
.mmu_version
, SPARCCPU
),
156 VMSTATE_STRUCT_ARRAY(env
.ts
, SPARCCPU
, MAXTL_MAX
, 0,
157 vmstate_trap_state
, trap_state
),
158 VMSTATE_UINT32(env
.xcc
, SPARCCPU
),
159 VMSTATE_UINT32(env
.asi
, SPARCCPU
),
160 VMSTATE_UINT32(env
.pstate
, SPARCCPU
),
161 VMSTATE_UINT32(env
.tl
, SPARCCPU
),
162 VMSTATE_UINT32(env
.cansave
, SPARCCPU
),
163 VMSTATE_UINT32(env
.canrestore
, SPARCCPU
),
164 VMSTATE_UINT32(env
.otherwin
, SPARCCPU
),
165 VMSTATE_UINT32(env
.wstate
, SPARCCPU
),
166 VMSTATE_UINT32(env
.cleanwin
, SPARCCPU
),
167 VMSTATE_UINT64_ARRAY(env
.agregs
, SPARCCPU
, 8),
168 VMSTATE_UINT64_ARRAY(env
.bgregs
, SPARCCPU
, 8),
169 VMSTATE_UINT64_ARRAY(env
.igregs
, SPARCCPU
, 8),
170 VMSTATE_UINT64_ARRAY(env
.mgregs
, SPARCCPU
, 8),
171 VMSTATE_UINT64(env
.fprs
, SPARCCPU
),
172 VMSTATE_UINT64(env
.tick_cmpr
, SPARCCPU
),
173 VMSTATE_UINT64(env
.stick_cmpr
, SPARCCPU
),
174 VMSTATE_CPU_TIMER(env
.tick
, SPARCCPU
),
175 VMSTATE_CPU_TIMER(env
.stick
, SPARCCPU
),
176 VMSTATE_UINT64(env
.gsr
, SPARCCPU
),
177 VMSTATE_UINT32(env
.gl
, SPARCCPU
),
178 VMSTATE_UINT64(env
.hpstate
, SPARCCPU
),
179 VMSTATE_UINT64_ARRAY(env
.htstate
, SPARCCPU
, MAXTL_MAX
),
180 VMSTATE_UINT64(env
.hintp
, SPARCCPU
),
181 VMSTATE_UINT64(env
.htba
, SPARCCPU
),
182 VMSTATE_UINT64(env
.hver
, SPARCCPU
),
183 VMSTATE_UINT64(env
.hstick_cmpr
, SPARCCPU
),
184 VMSTATE_UINT64(env
.ssr
, SPARCCPU
),
185 VMSTATE_CPU_TIMER(env
.hstick
, SPARCCPU
),
186 /* On SPARC32 env.psrpil and env.cwp are migrated as part of the PSR */
187 VMSTATE_UINT32(env
.psrpil
, SPARCCPU
),
188 VMSTATE_UINT32(env
.cwp
, SPARCCPU
),
190 VMSTATE_END_OF_LIST()