root / target-mips / translate_init.c @ ead9360e
History | View | Annotate | Download (15.9 kB)
1 |
/*
|
---|---|
2 |
* MIPS emulation for qemu: CPU initialisation routines.
|
3 |
*
|
4 |
* Copyright (c) 2004-2005 Jocelyn Mayer
|
5 |
* Copyright (c) 2007 Herve Poussineau
|
6 |
*
|
7 |
* This library is free software; you can redistribute it and/or
|
8 |
* modify it under the terms of the GNU Lesser General Public
|
9 |
* License as published by the Free Software Foundation; either
|
10 |
* version 2 of the License, or (at your option) any later version.
|
11 |
*
|
12 |
* This library is distributed in the hope that it will be useful,
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15 |
* Lesser General Public License for more details.
|
16 |
*
|
17 |
* You should have received a copy of the GNU Lesser General Public
|
18 |
* License along with this library; if not, write to the Free Software
|
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20 |
*/
|
21 |
|
22 |
/* CPU / CPU family specific config register values. */
|
23 |
|
24 |
/* Have config1, is MIPS32R1, uses TLB, no virtual icache,
|
25 |
uncached coherency */
|
26 |
#define MIPS_CONFIG0 \
|
27 |
((1 << CP0C0_M) | (0x0 << CP0C0_K23) | (0x0 << CP0C0_KU) | \ |
28 |
(0x0 << CP0C0_AT) | (0x0 << CP0C0_AR) | (0x1 << CP0C0_MT) | \ |
29 |
(0x2 << CP0C0_K0))
|
30 |
|
31 |
/* Have config2, no coprocessor2 attached, no MDMX support attached,
|
32 |
no performance counters, watch registers present,
|
33 |
no code compression, EJTAG present, no FPU */
|
34 |
#define MIPS_CONFIG1 \
|
35 |
((1 << CP0C1_M) | \
|
36 |
(0 << CP0C1_C2) | (0 << CP0C1_MD) | (0 << CP0C1_PC) | \ |
37 |
(1 << CP0C1_WR) | (0 << CP0C1_CA) | (1 << CP0C1_EP) | \ |
38 |
(0 << CP0C1_FP))
|
39 |
|
40 |
/* Have config3, no tertiary/secondary caches implemented */
|
41 |
#define MIPS_CONFIG2 \
|
42 |
((1 << CP0C2_M))
|
43 |
|
44 |
/* No config4, no DSP ASE, no large physaddr,
|
45 |
no external interrupt controller, no vectored interupts,
|
46 |
no 1kb pages, no SmartMIPS ASE, no trace logic */
|
47 |
#define MIPS_CONFIG3 \
|
48 |
((0 << CP0C3_M) | (0 << CP0C3_DSPP) | (0 << CP0C3_LPA) | \ |
49 |
(0 << CP0C3_VEIC) | (0 << CP0C3_VInt) | (0 << CP0C3_SP) | \ |
50 |
(0 << CP0C3_SM) | (0 << CP0C3_TL)) |
51 |
|
52 |
/* Define a implementation number of 1.
|
53 |
Define a major version 1, minor version 0. */
|
54 |
#define MIPS_FCR0 ((0 << FCR0_S) | (0x1 << FCR0_PRID) | (0x10 << FCR0_REV)) |
55 |
|
56 |
|
57 |
struct mips_def_t {
|
58 |
const unsigned char *name; |
59 |
int32_t CP0_PRid; |
60 |
int32_t CP0_Config0; |
61 |
int32_t CP0_Config1; |
62 |
int32_t CP0_Config2; |
63 |
int32_t CP0_Config3; |
64 |
int32_t CP0_Config6; |
65 |
int32_t CP0_Config7; |
66 |
int32_t SYNCI_Step; |
67 |
int32_t CCRes; |
68 |
int32_t CP0_Status_rw_bitmask; |
69 |
int32_t CP0_TCStatus_rw_bitmask; |
70 |
int32_t CP0_SRSCtl; |
71 |
int32_t CP1_fcr0; |
72 |
int32_t SEGBITS; |
73 |
int32_t CP0_SRSConf0_rw_bitmask; |
74 |
int32_t CP0_SRSConf0; |
75 |
int32_t CP0_SRSConf1_rw_bitmask; |
76 |
int32_t CP0_SRSConf1; |
77 |
int32_t CP0_SRSConf2_rw_bitmask; |
78 |
int32_t CP0_SRSConf2; |
79 |
int32_t CP0_SRSConf3_rw_bitmask; |
80 |
int32_t CP0_SRSConf3; |
81 |
int32_t CP0_SRSConf4_rw_bitmask; |
82 |
int32_t CP0_SRSConf4; |
83 |
}; |
84 |
|
85 |
/*****************************************************************************/
|
86 |
/* MIPS CPU definitions */
|
87 |
static mips_def_t mips_defs[] =
|
88 |
{ |
89 |
{ |
90 |
.name = "4Kc",
|
91 |
.CP0_PRid = 0x00018000,
|
92 |
.CP0_Config0 = MIPS_CONFIG0, |
93 |
.CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
|
94 |
(0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
95 |
(0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
96 |
.CP0_Config2 = MIPS_CONFIG2, |
97 |
.CP0_Config3 = MIPS_CONFIG3, |
98 |
.SYNCI_Step = 32,
|
99 |
.CCRes = 2,
|
100 |
.CP0_Status_rw_bitmask = 0x1278FF17,
|
101 |
}, |
102 |
{ |
103 |
.name = "4KEcR1",
|
104 |
.CP0_PRid = 0x00018400,
|
105 |
.CP0_Config0 = MIPS_CONFIG0, |
106 |
.CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
|
107 |
(0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
108 |
(0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
109 |
.CP0_Config2 = MIPS_CONFIG2, |
110 |
.CP0_Config3 = MIPS_CONFIG3, |
111 |
.SYNCI_Step = 32,
|
112 |
.CCRes = 2,
|
113 |
.CP0_Status_rw_bitmask = 0x1278FF17,
|
114 |
}, |
115 |
{ |
116 |
.name = "4KEc",
|
117 |
.CP0_PRid = 0x00019000,
|
118 |
.CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR),
|
119 |
.CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
|
120 |
(0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
121 |
(0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
122 |
.CP0_Config2 = MIPS_CONFIG2, |
123 |
.CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
|
124 |
.SYNCI_Step = 32,
|
125 |
.CCRes = 2,
|
126 |
.CP0_Status_rw_bitmask = 0x1278FF17,
|
127 |
}, |
128 |
{ |
129 |
.name = "24Kc",
|
130 |
.CP0_PRid = 0x00019300,
|
131 |
.CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR),
|
132 |
.CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
|
133 |
(0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
134 |
(0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
135 |
.CP0_Config2 = MIPS_CONFIG2, |
136 |
.CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
|
137 |
.SYNCI_Step = 32,
|
138 |
.CCRes = 2,
|
139 |
/* No DSP implemented. */
|
140 |
.CP0_Status_rw_bitmask = 0x1278FF17,
|
141 |
}, |
142 |
{ |
143 |
.name = "24Kf",
|
144 |
.CP0_PRid = 0x00019300,
|
145 |
.CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR),
|
146 |
.CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) | |
147 |
(0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
148 |
(0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
149 |
.CP0_Config2 = MIPS_CONFIG2, |
150 |
.CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
|
151 |
.SYNCI_Step = 32,
|
152 |
.CCRes = 2,
|
153 |
/* No DSP implemented. */
|
154 |
.CP0_Status_rw_bitmask = 0x3678FF17,
|
155 |
.CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) | |
156 |
(1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID), |
157 |
}, |
158 |
{ |
159 |
.name = "34Kf",
|
160 |
.CP0_PRid = 0x00019500,
|
161 |
.CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR),
|
162 |
.CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) | |
163 |
(0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
164 |
(0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
165 |
.CP0_Config2 = MIPS_CONFIG2, |
166 |
.CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt) | (1 << CP0C3_MT), |
167 |
.SYNCI_Step = 32,
|
168 |
.CCRes = 2,
|
169 |
/* No DSP implemented. */
|
170 |
.CP0_Status_rw_bitmask = 0x3678FF17,
|
171 |
/* No DSP implemented. */
|
172 |
.CP0_TCStatus_rw_bitmask = (0 << CP0TCSt_TCU3) | (0 << CP0TCSt_TCU2) | |
173 |
(1 << CP0TCSt_TCU1) | (1 << CP0TCSt_TCU0) | |
174 |
(0 << CP0TCSt_TMX) | (1 << CP0TCSt_DT) | |
175 |
(1 << CP0TCSt_DA) | (1 << CP0TCSt_A) | |
176 |
(0x3 << CP0TCSt_TKSU) | (1 << CP0TCSt_IXMT) | |
177 |
(0xff << CP0TCSt_TASID),
|
178 |
.CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) | |
179 |
(1 << FCR0_D) | (1 << FCR0_S) | (0x95 << FCR0_PRID), |
180 |
.CP0_SRSCtl = (0xf << CP0SRSCtl_HSS),
|
181 |
.CP0_SRSConf0_rw_bitmask = 0x3fffffff,
|
182 |
.CP0_SRSConf0 = (1 << CP0SRSC0_M) | (0x3fe << CP0SRSC0_SRS3) | |
183 |
(0x3fe << CP0SRSC0_SRS2) | (0x3fe << CP0SRSC0_SRS1), |
184 |
.CP0_SRSConf1_rw_bitmask = 0x3fffffff,
|
185 |
.CP0_SRSConf1 = (1 << CP0SRSC1_M) | (0x3fe << CP0SRSC1_SRS6) | |
186 |
(0x3fe << CP0SRSC1_SRS5) | (0x3fe << CP0SRSC1_SRS4), |
187 |
.CP0_SRSConf2_rw_bitmask = 0x3fffffff,
|
188 |
.CP0_SRSConf2 = (1 << CP0SRSC2_M) | (0x3fe << CP0SRSC2_SRS9) | |
189 |
(0x3fe << CP0SRSC2_SRS8) | (0x3fe << CP0SRSC2_SRS7), |
190 |
.CP0_SRSConf3_rw_bitmask = 0x3fffffff,
|
191 |
.CP0_SRSConf3 = (1 << CP0SRSC3_M) | (0x3fe << CP0SRSC3_SRS12) | |
192 |
(0x3fe << CP0SRSC3_SRS11) | (0x3fe << CP0SRSC3_SRS10), |
193 |
.CP0_SRSConf4_rw_bitmask = 0x3fffffff,
|
194 |
.CP0_SRSConf4 = (0x3fe << CP0SRSC4_SRS15) |
|
195 |
(0x3fe << CP0SRSC4_SRS14) | (0x3fe << CP0SRSC4_SRS13), |
196 |
}, |
197 |
#ifdef TARGET_MIPS64
|
198 |
{ |
199 |
.name = "R4000",
|
200 |
.CP0_PRid = 0x00000400,
|
201 |
.CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT),
|
202 |
.CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (47 << CP0C1_MMU) | |
203 |
(0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
204 |
(0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
205 |
.CP0_Config2 = MIPS_CONFIG2, |
206 |
.CP0_Config3 = MIPS_CONFIG3, |
207 |
.SYNCI_Step = 16,
|
208 |
.CCRes = 2,
|
209 |
.CP0_Status_rw_bitmask = 0x3678FFFF,
|
210 |
/* The R4000 has a full 64bit FPU doesn't use the fcr0 bits. */
|
211 |
.CP1_fcr0 = (0x5 << FCR0_PRID) | (0x0 << FCR0_REV), |
212 |
.SEGBITS = 40,
|
213 |
}, |
214 |
{ |
215 |
.name = "5Kc",
|
216 |
.CP0_PRid = 0x00018100,
|
217 |
.CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT),
|
218 |
.CP0_Config1 = MIPS_CONFIG1 | (31 << CP0C1_MMU) |
|
219 |
(1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) | |
220 |
(1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) | |
221 |
(1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), |
222 |
.CP0_Config2 = MIPS_CONFIG2, |
223 |
.CP0_Config3 = MIPS_CONFIG3, |
224 |
.SYNCI_Step = 32,
|
225 |
.CCRes = 2,
|
226 |
.CP0_Status_rw_bitmask = 0x32F8FFFF,
|
227 |
.SEGBITS = 42,
|
228 |
}, |
229 |
{ |
230 |
.name = "5Kf",
|
231 |
.CP0_PRid = 0x00018100,
|
232 |
.CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT),
|
233 |
.CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (31 << CP0C1_MMU) | |
234 |
(1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) | |
235 |
(1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) | |
236 |
(1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), |
237 |
.CP0_Config2 = MIPS_CONFIG2, |
238 |
.CP0_Config3 = MIPS_CONFIG3, |
239 |
.SYNCI_Step = 32,
|
240 |
.CCRes = 2,
|
241 |
.CP0_Status_rw_bitmask = 0x36F8FFFF,
|
242 |
/* The 5Kf has F64 / L / W but doesn't use the fcr0 bits. */
|
243 |
.CP1_fcr0 = (1 << FCR0_D) | (1 << FCR0_S) | |
244 |
(0x81 << FCR0_PRID) | (0x0 << FCR0_REV), |
245 |
.SEGBITS = 42,
|
246 |
}, |
247 |
{ |
248 |
.name = "20Kc",
|
249 |
/* We emulate a later version of the 20Kc, earlier ones had a broken
|
250 |
WAIT instruction. */
|
251 |
.CP0_PRid = 0x000182a0,
|
252 |
.CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) | (1 << CP0C0_VI), |
253 |
.CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (47 << CP0C1_MMU) | |
254 |
(2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) | |
255 |
(2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) | |
256 |
(1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), |
257 |
.CP0_Config2 = MIPS_CONFIG2, |
258 |
.CP0_Config3 = MIPS_CONFIG3, |
259 |
.SYNCI_Step = 32,
|
260 |
.CCRes = 2,
|
261 |
.CP0_Status_rw_bitmask = 0x36FBFFFF,
|
262 |
/* The 20Kc has F64 / L / W but doesn't use the fcr0 bits. */
|
263 |
.CP1_fcr0 = (1 << FCR0_3D) | (1 << FCR0_PS) | |
264 |
(1 << FCR0_D) | (1 << FCR0_S) | |
265 |
(0x82 << FCR0_PRID) | (0x0 << FCR0_REV), |
266 |
.SEGBITS = 40,
|
267 |
}, |
268 |
#endif
|
269 |
}; |
270 |
|
271 |
int mips_find_by_name (const unsigned char *name, mips_def_t **def) |
272 |
{ |
273 |
int i, ret;
|
274 |
|
275 |
ret = -1;
|
276 |
*def = NULL;
|
277 |
for (i = 0; i < sizeof(mips_defs) / sizeof(mips_defs[0]); i++) { |
278 |
if (strcasecmp(name, mips_defs[i].name) == 0) { |
279 |
*def = &mips_defs[i]; |
280 |
ret = 0;
|
281 |
break;
|
282 |
} |
283 |
} |
284 |
|
285 |
return ret;
|
286 |
} |
287 |
|
288 |
void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) |
289 |
{ |
290 |
int i;
|
291 |
|
292 |
for (i = 0; i < sizeof(mips_defs) / sizeof(mips_defs[0]); i++) { |
293 |
(*cpu_fprintf)(f, "MIPS '%s'\n",
|
294 |
mips_defs[i].name); |
295 |
} |
296 |
} |
297 |
|
298 |
#ifndef CONFIG_USER_ONLY
|
299 |
static void no_mmu_init (CPUMIPSState *env, mips_def_t *def) |
300 |
{ |
301 |
env->tlb->nb_tlb = 1;
|
302 |
env->tlb->map_address = &no_mmu_map_address; |
303 |
} |
304 |
|
305 |
static void fixed_mmu_init (CPUMIPSState *env, mips_def_t *def) |
306 |
{ |
307 |
env->tlb->nb_tlb = 1;
|
308 |
env->tlb->map_address = &fixed_mmu_map_address; |
309 |
} |
310 |
|
311 |
static void r4k_mmu_init (CPUMIPSState *env, mips_def_t *def) |
312 |
{ |
313 |
env->tlb->nb_tlb = 1 + ((def->CP0_Config1 >> CP0C1_MMU) & 63); |
314 |
env->tlb->map_address = &r4k_map_address; |
315 |
env->tlb->do_tlbwi = r4k_do_tlbwi; |
316 |
env->tlb->do_tlbwr = r4k_do_tlbwr; |
317 |
env->tlb->do_tlbp = r4k_do_tlbp; |
318 |
env->tlb->do_tlbr = r4k_do_tlbr; |
319 |
} |
320 |
|
321 |
static void mmu_init (CPUMIPSState *env, mips_def_t *def) |
322 |
{ |
323 |
env->tlb = qemu_mallocz(sizeof(CPUMIPSTLBContext));
|
324 |
|
325 |
/* There are more full-featured MMU variants in older MIPS CPUs,
|
326 |
R3000, R6000 and R8000 come to mind. If we ever support them,
|
327 |
this check will need to look up a different place than those
|
328 |
newfangled config registers. */
|
329 |
switch ((env->CP0_Config0 >> CP0C0_MT) & 3) { |
330 |
case 0: |
331 |
no_mmu_init(env, def); |
332 |
break;
|
333 |
case 1: |
334 |
r4k_mmu_init(env, def); |
335 |
break;
|
336 |
case 3: |
337 |
fixed_mmu_init(env, def); |
338 |
break;
|
339 |
default:
|
340 |
cpu_abort(env, "MMU type not supported\n");
|
341 |
} |
342 |
env->CP0_Random = env->tlb->nb_tlb - 1;
|
343 |
env->tlb->tlb_in_use = env->tlb->nb_tlb; |
344 |
} |
345 |
#endif /* CONFIG_USER_ONLY */ |
346 |
|
347 |
static void fpu_init (CPUMIPSState *env, mips_def_t *def) |
348 |
{ |
349 |
env->fpu = qemu_mallocz(sizeof(CPUMIPSFPUContext));
|
350 |
|
351 |
env->fpu->fcr0 = def->CP1_fcr0; |
352 |
#ifdef CONFIG_USER_ONLY
|
353 |
if (env->CP0_Config1 & (1 << CP0C1_FP)) |
354 |
env->hflags |= MIPS_HFLAG_FPU; |
355 |
if (env->fpu->fcr0 & (1 << FCR0_F64)) |
356 |
env->hflags |= MIPS_HFLAG_F64; |
357 |
#endif
|
358 |
} |
359 |
|
360 |
static void mvp_init (CPUMIPSState *env, mips_def_t *def) |
361 |
{ |
362 |
env->mvp = qemu_mallocz(sizeof(CPUMIPSMVPContext));
|
363 |
|
364 |
/* MVPConf1 implemented, TLB sharable, no gating storage support,
|
365 |
programmable cache partitioning implemented, number of allocatable
|
366 |
and sharable TLB entries, MVP has allocatable TCs, 2 VPEs
|
367 |
implemented, 5 TCs implemented. */
|
368 |
env->mvp->CP0_MVPConf0 = (1 << CP0MVPC0_M) | (1 << CP0MVPC0_TLBS) | |
369 |
(0 << CP0MVPC0_GS) | (1 << CP0MVPC0_PCP) | |
370 |
(env->tlb->nb_tlb << CP0MVPC0_PTLBE) | |
371 |
// TODO: actually do 2 VPEs.
|
372 |
// (1 << CP0MVPC0_TCA) | (0x1 << CP0MVPC0_PVPE) |
|
373 |
// (0x04 << CP0MVPC0_PTC);
|
374 |
(1 << CP0MVPC0_TCA) | (0x0 << CP0MVPC0_PVPE) | |
375 |
(0x04 << CP0MVPC0_PTC);
|
376 |
/* Allocatable CP1 have media extensions, allocatable CP1 have FP support,
|
377 |
no UDI implemented, no CP2 implemented, 1 CP1 implemented. */
|
378 |
env->mvp->CP0_MVPConf1 = (1 << CP0MVPC1_CIM) | (1 << CP0MVPC1_CIF) | |
379 |
(0x0 << CP0MVPC1_PCX) | (0x0 << CP0MVPC1_PCP2) | |
380 |
(0x1 << CP0MVPC1_PCP1);
|
381 |
} |
382 |
|
383 |
int cpu_mips_register (CPUMIPSState *env, mips_def_t *def)
|
384 |
{ |
385 |
if (!def)
|
386 |
def = env->cpu_model; |
387 |
if (!def)
|
388 |
cpu_abort(env, "Unable to find MIPS CPU definition\n");
|
389 |
env->cpu_model = def; |
390 |
env->CP0_PRid = def->CP0_PRid; |
391 |
env->CP0_Config0 = def->CP0_Config0; |
392 |
#ifdef TARGET_WORDS_BIGENDIAN
|
393 |
env->CP0_Config0 |= (1 << CP0C0_BE);
|
394 |
#endif
|
395 |
env->CP0_Config1 = def->CP0_Config1; |
396 |
env->CP0_Config2 = def->CP0_Config2; |
397 |
env->CP0_Config3 = def->CP0_Config3; |
398 |
env->CP0_Config6 = def->CP0_Config6; |
399 |
env->CP0_Config7 = def->CP0_Config7; |
400 |
env->SYNCI_Step = def->SYNCI_Step; |
401 |
env->CCRes = def->CCRes; |
402 |
env->CP0_Status_rw_bitmask = def->CP0_Status_rw_bitmask; |
403 |
env->CP0_TCStatus_rw_bitmask = def->CP0_TCStatus_rw_bitmask; |
404 |
env->CP0_SRSCtl = def->CP0_SRSCtl; |
405 |
#ifdef TARGET_MIPS64
|
406 |
if ((env->CP0_Config0 & (0x3 << CP0C0_AT))) |
407 |
{ |
408 |
env->hflags |= MIPS_HFLAG_64; |
409 |
env->SEGBITS = def->SEGBITS; |
410 |
env->SEGMask = (3ULL << 62) | ((1ULL << def->SEGBITS) - 1); |
411 |
} else {
|
412 |
env->SEGBITS = 32;
|
413 |
env->SEGMask = 0xFFFFFFFF;
|
414 |
} |
415 |
#endif
|
416 |
env->CP0_SRSConf0_rw_bitmask = def->CP0_SRSConf0_rw_bitmask; |
417 |
env->CP0_SRSConf0 = def->CP0_SRSConf0; |
418 |
env->CP0_SRSConf1_rw_bitmask = def->CP0_SRSConf1_rw_bitmask; |
419 |
env->CP0_SRSConf1 = def->CP0_SRSConf1; |
420 |
env->CP0_SRSConf2_rw_bitmask = def->CP0_SRSConf2_rw_bitmask; |
421 |
env->CP0_SRSConf2 = def->CP0_SRSConf2; |
422 |
env->CP0_SRSConf3_rw_bitmask = def->CP0_SRSConf3_rw_bitmask; |
423 |
env->CP0_SRSConf3 = def->CP0_SRSConf3; |
424 |
env->CP0_SRSConf4_rw_bitmask = def->CP0_SRSConf4_rw_bitmask; |
425 |
env->CP0_SRSConf4 = def->CP0_SRSConf4; |
426 |
|
427 |
#ifndef CONFIG_USER_ONLY
|
428 |
mmu_init(env, def); |
429 |
#endif
|
430 |
fpu_init(env, def); |
431 |
mvp_init(env, def); |
432 |
return 0; |
433 |
} |