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