Statistics
| Branch: | Revision:

root / target-sparc / machine.c @ 4f690853

History | View | Annotate | Download (6 kB)

1 8dd3dca3 aurel32
#include "hw/hw.h"
2 8dd3dca3 aurel32
#include "hw/boards.h"
3 0b8f1b10 blueswir1
#include "qemu-timer.h"
4 8dd3dca3 aurel32
5 8dd3dca3 aurel32
#include "exec-all.h"
6 8dd3dca3 aurel32
7 8dd3dca3 aurel32
void cpu_save(QEMUFile *f, void *opaque)
8 8dd3dca3 aurel32
{
9 8dd3dca3 aurel32
    CPUState *env = opaque;
10 8dd3dca3 aurel32
    int i;
11 8dd3dca3 aurel32
    uint32_t tmp;
12 8dd3dca3 aurel32
13 a7a044f2 blueswir1
    // if env->cwp == env->nwindows - 1, this will set the ins of the last
14 a7a044f2 blueswir1
    // window as the outs of the first window
15 a7a044f2 blueswir1
    cpu_set_cwp(env, env->cwp);
16 a7a044f2 blueswir1
17 8dd3dca3 aurel32
    for(i = 0; i < 8; i++)
18 8dd3dca3 aurel32
        qemu_put_betls(f, &env->gregs[i]);
19 1a14026e blueswir1
    qemu_put_be32s(f, &env->nwindows);
20 1a14026e blueswir1
    for(i = 0; i < env->nwindows * 16; i++)
21 8dd3dca3 aurel32
        qemu_put_betls(f, &env->regbase[i]);
22 8dd3dca3 aurel32
23 8dd3dca3 aurel32
    /* FPU */
24 8dd3dca3 aurel32
    for(i = 0; i < TARGET_FPREGS; i++) {
25 8dd3dca3 aurel32
        union {
26 8dd3dca3 aurel32
            float32 f;
27 8dd3dca3 aurel32
            uint32_t i;
28 8dd3dca3 aurel32
        } u;
29 8dd3dca3 aurel32
        u.f = env->fpr[i];
30 8dd3dca3 aurel32
        qemu_put_be32(f, u.i);
31 8dd3dca3 aurel32
    }
32 8dd3dca3 aurel32
33 8dd3dca3 aurel32
    qemu_put_betls(f, &env->pc);
34 8dd3dca3 aurel32
    qemu_put_betls(f, &env->npc);
35 8dd3dca3 aurel32
    qemu_put_betls(f, &env->y);
36 8dd3dca3 aurel32
    tmp = GET_PSR(env);
37 8dd3dca3 aurel32
    qemu_put_be32(f, tmp);
38 8dd3dca3 aurel32
    qemu_put_betls(f, &env->fsr);
39 8dd3dca3 aurel32
    qemu_put_betls(f, &env->tbr);
40 a7a044f2 blueswir1
    tmp = env->interrupt_index;
41 a7a044f2 blueswir1
    qemu_put_be32(f, tmp);
42 a7a044f2 blueswir1
    qemu_put_be32s(f, &env->pil_in);
43 8dd3dca3 aurel32
#ifndef TARGET_SPARC64
44 8dd3dca3 aurel32
    qemu_put_be32s(f, &env->wim);
45 8dd3dca3 aurel32
    /* MMU */
46 0b8f1b10 blueswir1
    for (i = 0; i < 32; i++)
47 8dd3dca3 aurel32
        qemu_put_be32s(f, &env->mmuregs[i]);
48 0b8f1b10 blueswir1
#else
49 0b8f1b10 blueswir1
    qemu_put_be64s(f, &env->lsu);
50 0b8f1b10 blueswir1
    for (i = 0; i < 16; i++) {
51 0b8f1b10 blueswir1
        qemu_put_be64s(f, &env->immuregs[i]);
52 0b8f1b10 blueswir1
        qemu_put_be64s(f, &env->dmmuregs[i]);
53 0b8f1b10 blueswir1
    }
54 0b8f1b10 blueswir1
    for (i = 0; i < 64; i++) {
55 6e8e7d4c Igor Kovalenko
        qemu_put_be64s(f, &env->itlb[i].tag);
56 6e8e7d4c Igor Kovalenko
        qemu_put_be64s(f, &env->itlb[i].tte);
57 6e8e7d4c Igor Kovalenko
        qemu_put_be64s(f, &env->dtlb[i].tag);
58 6e8e7d4c Igor Kovalenko
        qemu_put_be64s(f, &env->dtlb[i].tte);
59 0b8f1b10 blueswir1
    }
60 0b8f1b10 blueswir1
    qemu_put_be32s(f, &env->mmu_version);
61 c19148bd blueswir1
    for (i = 0; i < MAXTL_MAX; i++) {
62 0b8f1b10 blueswir1
        qemu_put_be64s(f, &env->ts[i].tpc);
63 0b8f1b10 blueswir1
        qemu_put_be64s(f, &env->ts[i].tnpc);
64 0b8f1b10 blueswir1
        qemu_put_be64s(f, &env->ts[i].tstate);
65 0b8f1b10 blueswir1
        qemu_put_be32s(f, &env->ts[i].tt);
66 0b8f1b10 blueswir1
    }
67 0b8f1b10 blueswir1
    qemu_put_be32s(f, &env->xcc);
68 0b8f1b10 blueswir1
    qemu_put_be32s(f, &env->asi);
69 0b8f1b10 blueswir1
    qemu_put_be32s(f, &env->pstate);
70 0b8f1b10 blueswir1
    qemu_put_be32s(f, &env->tl);
71 0b8f1b10 blueswir1
    qemu_put_be32s(f, &env->cansave);
72 0b8f1b10 blueswir1
    qemu_put_be32s(f, &env->canrestore);
73 0b8f1b10 blueswir1
    qemu_put_be32s(f, &env->otherwin);
74 0b8f1b10 blueswir1
    qemu_put_be32s(f, &env->wstate);
75 0b8f1b10 blueswir1
    qemu_put_be32s(f, &env->cleanwin);
76 0b8f1b10 blueswir1
    for (i = 0; i < 8; i++)
77 0b8f1b10 blueswir1
        qemu_put_be64s(f, &env->agregs[i]);
78 0b8f1b10 blueswir1
    for (i = 0; i < 8; i++)
79 0b8f1b10 blueswir1
        qemu_put_be64s(f, &env->bgregs[i]);
80 0b8f1b10 blueswir1
    for (i = 0; i < 8; i++)
81 0b8f1b10 blueswir1
        qemu_put_be64s(f, &env->igregs[i]);
82 0b8f1b10 blueswir1
    for (i = 0; i < 8; i++)
83 0b8f1b10 blueswir1
        qemu_put_be64s(f, &env->mgregs[i]);
84 0b8f1b10 blueswir1
    qemu_put_be64s(f, &env->fprs);
85 0b8f1b10 blueswir1
    qemu_put_be64s(f, &env->tick_cmpr);
86 0b8f1b10 blueswir1
    qemu_put_be64s(f, &env->stick_cmpr);
87 0b8f1b10 blueswir1
    qemu_put_ptimer(f, env->tick);
88 0b8f1b10 blueswir1
    qemu_put_ptimer(f, env->stick);
89 0b8f1b10 blueswir1
    qemu_put_be64s(f, &env->gsr);
90 0b8f1b10 blueswir1
    qemu_put_be32s(f, &env->gl);
91 0b8f1b10 blueswir1
    qemu_put_be64s(f, &env->hpstate);
92 c19148bd blueswir1
    for (i = 0; i < MAXTL_MAX; i++)
93 0b8f1b10 blueswir1
        qemu_put_be64s(f, &env->htstate[i]);
94 0b8f1b10 blueswir1
    qemu_put_be64s(f, &env->hintp);
95 0b8f1b10 blueswir1
    qemu_put_be64s(f, &env->htba);
96 0b8f1b10 blueswir1
    qemu_put_be64s(f, &env->hver);
97 0b8f1b10 blueswir1
    qemu_put_be64s(f, &env->hstick_cmpr);
98 0b8f1b10 blueswir1
    qemu_put_be64s(f, &env->ssr);
99 a7a044f2 blueswir1
    qemu_put_ptimer(f, env->hstick);
100 8dd3dca3 aurel32
#endif
101 8dd3dca3 aurel32
}
102 8dd3dca3 aurel32
103 8dd3dca3 aurel32
int cpu_load(QEMUFile *f, void *opaque, int version_id)
104 8dd3dca3 aurel32
{
105 8dd3dca3 aurel32
    CPUState *env = opaque;
106 8dd3dca3 aurel32
    int i;
107 8dd3dca3 aurel32
    uint32_t tmp;
108 8dd3dca3 aurel32
109 0b8f1b10 blueswir1
    if (version_id != 5)
110 1a14026e blueswir1
        return -EINVAL;
111 8dd3dca3 aurel32
    for(i = 0; i < 8; i++)
112 8dd3dca3 aurel32
        qemu_get_betls(f, &env->gregs[i]);
113 1a14026e blueswir1
    qemu_get_be32s(f, &env->nwindows);
114 1a14026e blueswir1
    for(i = 0; i < env->nwindows * 16; i++)
115 8dd3dca3 aurel32
        qemu_get_betls(f, &env->regbase[i]);
116 8dd3dca3 aurel32
117 8dd3dca3 aurel32
    /* FPU */
118 8dd3dca3 aurel32
    for(i = 0; i < TARGET_FPREGS; i++) {
119 8dd3dca3 aurel32
        union {
120 8dd3dca3 aurel32
            float32 f;
121 8dd3dca3 aurel32
            uint32_t i;
122 8dd3dca3 aurel32
        } u;
123 8dd3dca3 aurel32
        u.i = qemu_get_be32(f);
124 8dd3dca3 aurel32
        env->fpr[i] = u.f;
125 8dd3dca3 aurel32
    }
126 8dd3dca3 aurel32
127 8dd3dca3 aurel32
    qemu_get_betls(f, &env->pc);
128 8dd3dca3 aurel32
    qemu_get_betls(f, &env->npc);
129 8dd3dca3 aurel32
    qemu_get_betls(f, &env->y);
130 8dd3dca3 aurel32
    tmp = qemu_get_be32(f);
131 8dd3dca3 aurel32
    env->cwp = 0; /* needed to ensure that the wrapping registers are
132 8dd3dca3 aurel32
                     correctly updated */
133 8dd3dca3 aurel32
    PUT_PSR(env, tmp);
134 8dd3dca3 aurel32
    qemu_get_betls(f, &env->fsr);
135 8dd3dca3 aurel32
    qemu_get_betls(f, &env->tbr);
136 a7a044f2 blueswir1
    tmp = qemu_get_be32(f);
137 a7a044f2 blueswir1
    env->interrupt_index = tmp;
138 a7a044f2 blueswir1
    qemu_get_be32s(f, &env->pil_in);
139 8dd3dca3 aurel32
#ifndef TARGET_SPARC64
140 8dd3dca3 aurel32
    qemu_get_be32s(f, &env->wim);
141 8dd3dca3 aurel32
    /* MMU */
142 0b8f1b10 blueswir1
    for (i = 0; i < 32; i++)
143 8dd3dca3 aurel32
        qemu_get_be32s(f, &env->mmuregs[i]);
144 0b8f1b10 blueswir1
#else
145 0b8f1b10 blueswir1
    qemu_get_be64s(f, &env->lsu);
146 0b8f1b10 blueswir1
    for (i = 0; i < 16; i++) {
147 0b8f1b10 blueswir1
        qemu_get_be64s(f, &env->immuregs[i]);
148 0b8f1b10 blueswir1
        qemu_get_be64s(f, &env->dmmuregs[i]);
149 0b8f1b10 blueswir1
    }
150 0b8f1b10 blueswir1
    for (i = 0; i < 64; i++) {
151 6e8e7d4c Igor Kovalenko
        qemu_get_be64s(f, &env->itlb[i].tag);
152 6e8e7d4c Igor Kovalenko
        qemu_get_be64s(f, &env->itlb[i].tte);
153 6e8e7d4c Igor Kovalenko
        qemu_get_be64s(f, &env->dtlb[i].tag);
154 6e8e7d4c Igor Kovalenko
        qemu_get_be64s(f, &env->dtlb[i].tte);
155 0b8f1b10 blueswir1
    }
156 0b8f1b10 blueswir1
    qemu_get_be32s(f, &env->mmu_version);
157 c19148bd blueswir1
    for (i = 0; i < MAXTL_MAX; i++) {
158 0b8f1b10 blueswir1
        qemu_get_be64s(f, &env->ts[i].tpc);
159 0b8f1b10 blueswir1
        qemu_get_be64s(f, &env->ts[i].tnpc);
160 0b8f1b10 blueswir1
        qemu_get_be64s(f, &env->ts[i].tstate);
161 0b8f1b10 blueswir1
        qemu_get_be32s(f, &env->ts[i].tt);
162 0b8f1b10 blueswir1
    }
163 0b8f1b10 blueswir1
    qemu_get_be32s(f, &env->xcc);
164 0b8f1b10 blueswir1
    qemu_get_be32s(f, &env->asi);
165 0b8f1b10 blueswir1
    qemu_get_be32s(f, &env->pstate);
166 0b8f1b10 blueswir1
    qemu_get_be32s(f, &env->tl);
167 0b8f1b10 blueswir1
    qemu_get_be32s(f, &env->cansave);
168 0b8f1b10 blueswir1
    qemu_get_be32s(f, &env->canrestore);
169 0b8f1b10 blueswir1
    qemu_get_be32s(f, &env->otherwin);
170 0b8f1b10 blueswir1
    qemu_get_be32s(f, &env->wstate);
171 0b8f1b10 blueswir1
    qemu_get_be32s(f, &env->cleanwin);
172 0b8f1b10 blueswir1
    for (i = 0; i < 8; i++)
173 0b8f1b10 blueswir1
        qemu_get_be64s(f, &env->agregs[i]);
174 0b8f1b10 blueswir1
    for (i = 0; i < 8; i++)
175 0b8f1b10 blueswir1
        qemu_get_be64s(f, &env->bgregs[i]);
176 0b8f1b10 blueswir1
    for (i = 0; i < 8; i++)
177 0b8f1b10 blueswir1
        qemu_get_be64s(f, &env->igregs[i]);
178 0b8f1b10 blueswir1
    for (i = 0; i < 8; i++)
179 0b8f1b10 blueswir1
        qemu_get_be64s(f, &env->mgregs[i]);
180 0b8f1b10 blueswir1
    qemu_get_be64s(f, &env->fprs);
181 0b8f1b10 blueswir1
    qemu_get_be64s(f, &env->tick_cmpr);
182 0b8f1b10 blueswir1
    qemu_get_be64s(f, &env->stick_cmpr);
183 0b8f1b10 blueswir1
    qemu_get_ptimer(f, env->tick);
184 0b8f1b10 blueswir1
    qemu_get_ptimer(f, env->stick);
185 0b8f1b10 blueswir1
    qemu_get_be64s(f, &env->gsr);
186 0b8f1b10 blueswir1
    qemu_get_be32s(f, &env->gl);
187 0b8f1b10 blueswir1
    qemu_get_be64s(f, &env->hpstate);
188 c19148bd blueswir1
    for (i = 0; i < MAXTL_MAX; i++)
189 0b8f1b10 blueswir1
        qemu_get_be64s(f, &env->htstate[i]);
190 0b8f1b10 blueswir1
    qemu_get_be64s(f, &env->hintp);
191 0b8f1b10 blueswir1
    qemu_get_be64s(f, &env->htba);
192 0b8f1b10 blueswir1
    qemu_get_be64s(f, &env->hver);
193 0b8f1b10 blueswir1
    qemu_get_be64s(f, &env->hstick_cmpr);
194 0b8f1b10 blueswir1
    qemu_get_be64s(f, &env->ssr);
195 0b8f1b10 blueswir1
    qemu_get_ptimer(f, env->hstick);
196 8dd3dca3 aurel32
#endif
197 8dd3dca3 aurel32
    tlb_flush(env, 1);
198 8dd3dca3 aurel32
    return 0;
199 8dd3dca3 aurel32
}