2 * MIPS emulation for qemu: CPU initialisation routines.
4 * Copyright (c) 2004-2005 Jocelyn Mayer
5 * Copyright (c) 2007 Herve Poussineau
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.
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.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 /* CPU / CPU family specific config register values. */
23 /* Have config1, uncached coherency */
24 #define MIPS_CONFIG0 \
25 ((1 << CP0C0_M) | (0x2 << CP0C0_K0))
27 /* Have config2, no coprocessor2 attached, no MDMX support attached,
28 no performance counters, watch registers present,
29 no code compression, EJTAG present, no FPU */
30 #define MIPS_CONFIG1 \
32 (0 << CP0C1_C2) | (0 << CP0C1_MD) | (0 << CP0C1_PC) | \
33 (1 << CP0C1_WR) | (0 << CP0C1_CA) | (1 << CP0C1_EP) | \
36 /* Have config3, no tertiary/secondary caches implemented */
37 #define MIPS_CONFIG2 \
40 /* No config4, no DSP ASE, no large physaddr (PABITS),
41 no external interrupt controller, no vectored interrupts,
42 no 1kb pages, no SmartMIPS ASE, no trace logic */
43 #define MIPS_CONFIG3 \
44 ((0 << CP0C3_M) | (0 << CP0C3_DSPP) | (0 << CP0C3_LPA) | \
45 (0 << CP0C3_VEIC) | (0 << CP0C3_VInt) | (0 << CP0C3_SP) | \
46 (0 << CP0C3_SM) | (0 << CP0C3_TL))
48 #define MIPS_CONFIG4 \
51 /* MMU types, the first four entries have the same layout as the
71 int32_t CP0_Config4_rw_bitmask;
74 target_ulong CP0_LLAddr_rw_bitmask;
78 int32_t CP0_Status_rw_bitmask;
79 int32_t CP0_TCStatus_rw_bitmask;
84 int32_t CP0_SRSConf0_rw_bitmask;
86 int32_t CP0_SRSConf1_rw_bitmask;
88 int32_t CP0_SRSConf2_rw_bitmask;
90 int32_t CP0_SRSConf3_rw_bitmask;
92 int32_t CP0_SRSConf4_rw_bitmask;
95 enum mips_mmu_types mmu_type;
98 /*****************************************************************************/
99 /* MIPS CPU definitions */
100 static const mips_def_t mips_defs[] =
104 .CP0_PRid = 0x00018000,
105 .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_R4000 << CP0C0_MT),
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) |
110 .CP0_Config2 = MIPS_CONFIG2,
111 .CP0_Config3 = MIPS_CONFIG3,
112 .CP0_LLAddr_rw_bitmask = 0,
113 .CP0_LLAddr_shift = 4,
116 .CP0_Status_rw_bitmask = 0x1278FF17,
119 .insn_flags = CPU_MIPS32,
120 .mmu_type = MMU_TYPE_R4000,
124 .CP0_PRid = 0x00018300,
125 /* Config1 implemented, fixed mapping MMU,
126 no virtual icache, uncached coherency. */
127 .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_FMT << CP0C0_MT),
128 .CP0_Config1 = MIPS_CONFIG1 |
129 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
130 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
132 .CP0_Config2 = MIPS_CONFIG2,
133 .CP0_Config3 = MIPS_CONFIG3,
134 .CP0_LLAddr_rw_bitmask = 0,
135 .CP0_LLAddr_shift = 4,
138 .CP0_Status_rw_bitmask = 0x1258FF17,
141 .insn_flags = CPU_MIPS32 | ASE_MIPS16,
142 .mmu_type = MMU_TYPE_FMT,
146 .CP0_PRid = 0x00018400,
147 .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_R4000 << CP0C0_MT),
148 .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
149 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
150 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
152 .CP0_Config2 = MIPS_CONFIG2,
153 .CP0_Config3 = MIPS_CONFIG3,
154 .CP0_LLAddr_rw_bitmask = 0,
155 .CP0_LLAddr_shift = 4,
158 .CP0_Status_rw_bitmask = 0x1278FF17,
161 .insn_flags = CPU_MIPS32,
162 .mmu_type = MMU_TYPE_R4000,
166 .CP0_PRid = 0x00018500,
167 .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_FMT << CP0C0_MT),
168 .CP0_Config1 = MIPS_CONFIG1 |
169 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
170 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
172 .CP0_Config2 = MIPS_CONFIG2,
173 .CP0_Config3 = MIPS_CONFIG3,
174 .CP0_LLAddr_rw_bitmask = 0,
175 .CP0_LLAddr_shift = 4,
178 .CP0_Status_rw_bitmask = 0x1258FF17,
181 .insn_flags = CPU_MIPS32 | ASE_MIPS16,
182 .mmu_type = MMU_TYPE_FMT,
186 .CP0_PRid = 0x00019000,
187 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
188 (MMU_TYPE_R4000 << CP0C0_MT),
189 .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
190 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
191 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
193 .CP0_Config2 = MIPS_CONFIG2,
194 .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
195 .CP0_LLAddr_rw_bitmask = 0,
196 .CP0_LLAddr_shift = 4,
199 .CP0_Status_rw_bitmask = 0x1278FF17,
202 .insn_flags = CPU_MIPS32R2,
203 .mmu_type = MMU_TYPE_R4000,
207 .CP0_PRid = 0x00019100,
208 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
209 (MMU_TYPE_FMT << CP0C0_MT),
210 .CP0_Config1 = MIPS_CONFIG1 |
211 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
212 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
214 .CP0_Config2 = MIPS_CONFIG2,
215 .CP0_Config3 = MIPS_CONFIG3,
216 .CP0_LLAddr_rw_bitmask = 0,
217 .CP0_LLAddr_shift = 4,
220 .CP0_Status_rw_bitmask = 0x1258FF17,
223 .insn_flags = CPU_MIPS32R2 | ASE_MIPS16,
224 .mmu_type = MMU_TYPE_FMT,
228 .CP0_PRid = 0x00019300,
229 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
230 (MMU_TYPE_R4000 << CP0C0_MT),
231 .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
232 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
233 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
235 .CP0_Config2 = MIPS_CONFIG2,
236 .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
237 .CP0_LLAddr_rw_bitmask = 0,
238 .CP0_LLAddr_shift = 4,
241 /* No DSP implemented. */
242 .CP0_Status_rw_bitmask = 0x1278FF1F,
245 .insn_flags = CPU_MIPS32R2 | ASE_MIPS16,
246 .mmu_type = MMU_TYPE_R4000,
250 .CP0_PRid = 0x00019300,
251 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
252 (MMU_TYPE_R4000 << CP0C0_MT),
253 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
254 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
255 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
257 .CP0_Config2 = MIPS_CONFIG2,
258 .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
259 .CP0_LLAddr_rw_bitmask = 0,
260 .CP0_LLAddr_shift = 4,
263 /* No DSP implemented. */
264 .CP0_Status_rw_bitmask = 0x3678FF1F,
265 .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
266 (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID),
269 .insn_flags = CPU_MIPS32R2 | ASE_MIPS16,
270 .mmu_type = MMU_TYPE_R4000,
274 .CP0_PRid = 0x00019500,
275 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
276 (MMU_TYPE_R4000 << CP0C0_MT),
277 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
278 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
279 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
281 .CP0_Config2 = MIPS_CONFIG2,
282 .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_VInt) | (1 << CP0C3_MT) |
284 .CP0_LLAddr_rw_bitmask = 0,
285 .CP0_LLAddr_shift = 0,
288 .CP0_Status_rw_bitmask = 0x3778FF1F,
289 .CP0_TCStatus_rw_bitmask = (0 << CP0TCSt_TCU3) | (0 << CP0TCSt_TCU2) |
290 (1 << CP0TCSt_TCU1) | (1 << CP0TCSt_TCU0) |
291 (0 << CP0TCSt_TMX) | (1 << CP0TCSt_DT) |
292 (1 << CP0TCSt_DA) | (1 << CP0TCSt_A) |
293 (0x3 << CP0TCSt_TKSU) | (1 << CP0TCSt_IXMT) |
294 (0xff << CP0TCSt_TASID),
295 .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
296 (1 << FCR0_D) | (1 << FCR0_S) | (0x95 << FCR0_PRID),
297 .CP0_SRSCtl = (0xf << CP0SRSCtl_HSS),
298 .CP0_SRSConf0_rw_bitmask = 0x3fffffff,
299 .CP0_SRSConf0 = (1 << CP0SRSC0_M) | (0x3fe << CP0SRSC0_SRS3) |
300 (0x3fe << CP0SRSC0_SRS2) | (0x3fe << CP0SRSC0_SRS1),
301 .CP0_SRSConf1_rw_bitmask = 0x3fffffff,
302 .CP0_SRSConf1 = (1 << CP0SRSC1_M) | (0x3fe << CP0SRSC1_SRS6) |
303 (0x3fe << CP0SRSC1_SRS5) | (0x3fe << CP0SRSC1_SRS4),
304 .CP0_SRSConf2_rw_bitmask = 0x3fffffff,
305 .CP0_SRSConf2 = (1 << CP0SRSC2_M) | (0x3fe << CP0SRSC2_SRS9) |
306 (0x3fe << CP0SRSC2_SRS8) | (0x3fe << CP0SRSC2_SRS7),
307 .CP0_SRSConf3_rw_bitmask = 0x3fffffff,
308 .CP0_SRSConf3 = (1 << CP0SRSC3_M) | (0x3fe << CP0SRSC3_SRS12) |
309 (0x3fe << CP0SRSC3_SRS11) | (0x3fe << CP0SRSC3_SRS10),
310 .CP0_SRSConf4_rw_bitmask = 0x3fffffff,
311 .CP0_SRSConf4 = (0x3fe << CP0SRSC4_SRS15) |
312 (0x3fe << CP0SRSC4_SRS14) | (0x3fe << CP0SRSC4_SRS13),
315 .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_MT,
316 .mmu_type = MMU_TYPE_R4000,
320 .CP0_PRid = 0x00019700,
321 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
322 (MMU_TYPE_R4000 << CP0C0_MT),
323 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
324 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
325 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
327 .CP0_Config2 = MIPS_CONFIG2,
328 .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt) | (1 << CP0C3_DSPP),
329 .CP0_LLAddr_rw_bitmask = 0,
330 .CP0_LLAddr_shift = 4,
333 .CP0_Status_rw_bitmask = 0x3778FF1F,
334 .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
335 (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID),
338 .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_DSPR2,
339 .mmu_type = MMU_TYPE_R4000,
342 /* A generic CPU providing MIPS32 Release 5 features.
343 FIXME: Eventually this should be replaced by a real CPU model. */
344 .name = "mips32r5-generic",
345 .CP0_PRid = 0x00019700,
346 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
347 (MMU_TYPE_R4000 << CP0C0_MT),
348 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
349 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
350 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
352 .CP0_Config2 = MIPS_CONFIG2,
353 .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_M),
354 .CP0_Config4 = MIPS_CONFIG4,
355 .CP0_Config4_rw_bitmask = 0,
356 .CP0_LLAddr_rw_bitmask = 0,
357 .CP0_LLAddr_shift = 4,
360 .CP0_Status_rw_bitmask = 0x3778FF1F,
361 .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
362 (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID),
365 .insn_flags = CPU_MIPS32R5 | ASE_MIPS16 | ASE_DSP | ASE_DSPR2,
366 .mmu_type = MMU_TYPE_R4000,
368 #if defined(TARGET_MIPS64)
371 .CP0_PRid = 0x00000400,
372 /* No L2 cache, icache size 8k, dcache size 8k, uncached coherency. */
373 .CP0_Config0 = (1 << 17) | (0x1 << 9) | (0x1 << 6) | (0x2 << CP0C0_K0),
374 /* Note: Config1 is only used internally, the R4000 has only Config0. */
375 .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
376 .CP0_LLAddr_rw_bitmask = 0xFFFFFFFF,
377 .CP0_LLAddr_shift = 4,
380 .CP0_Status_rw_bitmask = 0x3678FFFF,
381 /* The R4000 has a full 64bit FPU but doesn't use the fcr0 bits. */
382 .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x0 << FCR0_REV),
385 .insn_flags = CPU_MIPS3,
386 .mmu_type = MMU_TYPE_R4000,
390 .CP0_PRid = 0x00005400,
391 /* No L2 cache, icache size 8k, dcache size 8k, uncached coherency. */
392 .CP0_Config0 = (1 << 17) | (0x1 << 9) | (0x1 << 6) | (0x2 << CP0C0_K0),
393 .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
394 .CP0_LLAddr_rw_bitmask = 0xFFFFFFFFL,
395 .CP0_LLAddr_shift = 4,
398 .CP0_Status_rw_bitmask = 0x3678FFFF,
399 /* The VR5432 has a full 64bit FPU but doesn't use the fcr0 bits. */
400 .CP1_fcr0 = (0x54 << FCR0_PRID) | (0x0 << FCR0_REV),
403 .insn_flags = CPU_VR54XX,
404 .mmu_type = MMU_TYPE_R4000,
408 .CP0_PRid = 0x00018100,
409 .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) |
410 (MMU_TYPE_R4000 << CP0C0_MT),
411 .CP0_Config1 = MIPS_CONFIG1 | (31 << CP0C1_MMU) |
412 (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) |
413 (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) |
414 (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
415 .CP0_Config2 = MIPS_CONFIG2,
416 .CP0_Config3 = MIPS_CONFIG3,
417 .CP0_LLAddr_rw_bitmask = 0,
418 .CP0_LLAddr_shift = 4,
421 .CP0_Status_rw_bitmask = 0x32F8FFFF,
424 .insn_flags = CPU_MIPS64,
425 .mmu_type = MMU_TYPE_R4000,
429 .CP0_PRid = 0x00018100,
430 .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) |
431 (MMU_TYPE_R4000 << CP0C0_MT),
432 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (31 << CP0C1_MMU) |
433 (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) |
434 (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) |
435 (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
436 .CP0_Config2 = MIPS_CONFIG2,
437 .CP0_Config3 = MIPS_CONFIG3,
438 .CP0_LLAddr_rw_bitmask = 0,
439 .CP0_LLAddr_shift = 4,
442 .CP0_Status_rw_bitmask = 0x36F8FFFF,
443 /* The 5Kf has F64 / L / W but doesn't use the fcr0 bits. */
444 .CP1_fcr0 = (1 << FCR0_D) | (1 << FCR0_S) |
445 (0x81 << FCR0_PRID) | (0x0 << FCR0_REV),
448 .insn_flags = CPU_MIPS64,
449 .mmu_type = MMU_TYPE_R4000,
453 /* We emulate a later version of the 20Kc, earlier ones had a broken
455 .CP0_PRid = 0x000182a0,
456 .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) |
457 (MMU_TYPE_R4000 << CP0C0_MT) | (1 << CP0C0_VI),
458 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (47 << CP0C1_MMU) |
459 (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
460 (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
461 (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
462 .CP0_Config2 = MIPS_CONFIG2,
463 .CP0_Config3 = MIPS_CONFIG3,
464 .CP0_LLAddr_rw_bitmask = 0,
465 .CP0_LLAddr_shift = 0,
468 .CP0_Status_rw_bitmask = 0x36FBFFFF,
469 /* The 20Kc has F64 / L / W but doesn't use the fcr0 bits. */
470 .CP1_fcr0 = (1 << FCR0_3D) | (1 << FCR0_PS) |
471 (1 << FCR0_D) | (1 << FCR0_S) |
472 (0x82 << FCR0_PRID) | (0x0 << FCR0_REV),
475 .insn_flags = CPU_MIPS64 | ASE_MIPS3D,
476 .mmu_type = MMU_TYPE_R4000,
479 /* A generic CPU providing MIPS64 Release 2 features.
480 FIXME: Eventually this should be replaced by a real CPU model. */
481 .name = "MIPS64R2-generic",
482 .CP0_PRid = 0x00010000,
483 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
484 (MMU_TYPE_R4000 << CP0C0_MT),
485 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) |
486 (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
487 (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
488 (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
489 .CP0_Config2 = MIPS_CONFIG2,
490 .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA),
491 .CP0_LLAddr_rw_bitmask = 0,
492 .CP0_LLAddr_shift = 0,
495 .CP0_Status_rw_bitmask = 0x36FBFFFF,
496 .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_3D) | (1 << FCR0_PS) |
497 (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
498 (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV),
500 /* The architectural limit is 59, but we have hardcoded 36 bit
502 .PABITS = 59, */ /* the architectural limit */
504 .insn_flags = CPU_MIPS64R2 | ASE_MIPS3D,
505 .mmu_type = MMU_TYPE_R4000,
508 .name = "Loongson-2E",
510 /*64KB I-cache and d-cache. 4 way with 32 bit cache line size*/
511 .CP0_Config0 = (0x1<<17) | (0x1<<16) | (0x1<<11) | (0x1<<8) | (0x1<<5) |
513 /* Note: Config1 is only used internally, Loongson-2E has only Config0. */
514 .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
517 .CP0_Status_rw_bitmask = 0x35D0FFFF,
518 .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x1 << FCR0_REV),
521 .insn_flags = CPU_LOONGSON2E,
522 .mmu_type = MMU_TYPE_R4000,
525 .name = "Loongson-2F",
527 /*64KB I-cache and d-cache. 4 way with 32 bit cache line size*/
528 .CP0_Config0 = (0x1<<17) | (0x1<<16) | (0x1<<11) | (0x1<<8) | (0x1<<5) |
530 /* Note: Config1 is only used internally, Loongson-2F has only Config0. */
531 .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
534 .CP0_Status_rw_bitmask = 0xF5D0FF1F, /*bit5:7 not writable*/
535 .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x1 << FCR0_REV),
538 .insn_flags = CPU_LOONGSON2F,
539 .mmu_type = MMU_TYPE_R4000,
542 /* A generic CPU providing MIPS64 ASE DSP 2 features.
543 FIXME: Eventually this should be replaced by a real CPU model. */
544 .name = "mips64dspr2",
545 .CP0_PRid = 0x00010000,
546 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
547 (MMU_TYPE_R4000 << CP0C0_MT),
548 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) |
549 (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
550 (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
551 (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
552 .CP0_Config2 = MIPS_CONFIG2,
553 .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA),
554 .CP0_LLAddr_rw_bitmask = 0,
555 .CP0_LLAddr_shift = 0,
558 .CP0_Status_rw_bitmask = 0x37FBFFFF,
559 .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_3D) | (1 << FCR0_PS) |
560 (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
561 (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV),
563 /* The architectural limit is 59, but we have hardcoded 36 bit
565 .PABITS = 59, */ /* the architectural limit */
567 .insn_flags = CPU_MIPS64R2 | ASE_DSP | ASE_DSPR2,
568 .mmu_type = MMU_TYPE_R4000,
574 static const mips_def_t *cpu_mips_find_by_name (const char *name)
578 for (i = 0; i < ARRAY_SIZE(mips_defs); i++) {
579 if (strcasecmp(name, mips_defs[i].name) == 0) {
580 return &mips_defs[i];
586 void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf)
590 for (i = 0; i < ARRAY_SIZE(mips_defs); i++) {
591 (*cpu_fprintf)(f, "MIPS '%s'\n",
596 #ifndef CONFIG_USER_ONLY
597 static void no_mmu_init (CPUMIPSState *env, const mips_def_t *def)
599 env->tlb->nb_tlb = 1;
600 env->tlb->map_address = &no_mmu_map_address;
603 static void fixed_mmu_init (CPUMIPSState *env, const mips_def_t *def)
605 env->tlb->nb_tlb = 1;
606 env->tlb->map_address = &fixed_mmu_map_address;
609 static void r4k_mmu_init (CPUMIPSState *env, const mips_def_t *def)
611 env->tlb->nb_tlb = 1 + ((def->CP0_Config1 >> CP0C1_MMU) & 63);
612 env->tlb->map_address = &r4k_map_address;
613 env->tlb->helper_tlbwi = r4k_helper_tlbwi;
614 env->tlb->helper_tlbwr = r4k_helper_tlbwr;
615 env->tlb->helper_tlbp = r4k_helper_tlbp;
616 env->tlb->helper_tlbr = r4k_helper_tlbr;
619 static void mmu_init (CPUMIPSState *env, const mips_def_t *def)
621 env->tlb = g_malloc0(sizeof(CPUMIPSTLBContext));
623 switch (def->mmu_type) {
625 no_mmu_init(env, def);
628 r4k_mmu_init(env, def);
631 fixed_mmu_init(env, def);
637 cpu_abort(env, "MMU type not supported\n");
640 #endif /* CONFIG_USER_ONLY */
642 static void fpu_init (CPUMIPSState *env, const mips_def_t *def)
646 for (i = 0; i < MIPS_FPU_MAX; i++)
647 env->fpus[i].fcr0 = def->CP1_fcr0;
649 memcpy(&env->active_fpu, &env->fpus[0], sizeof(env->active_fpu));
652 static void mvp_init (CPUMIPSState *env, const mips_def_t *def)
654 env->mvp = g_malloc0(sizeof(CPUMIPSMVPContext));
656 /* MVPConf1 implemented, TLB sharable, no gating storage support,
657 programmable cache partitioning implemented, number of allocatable
658 and sharable TLB entries, MVP has allocatable TCs, 2 VPEs
659 implemented, 5 TCs implemented. */
660 env->mvp->CP0_MVPConf0 = (1 << CP0MVPC0_M) | (1 << CP0MVPC0_TLBS) |
661 (0 << CP0MVPC0_GS) | (1 << CP0MVPC0_PCP) |
662 // TODO: actually do 2 VPEs.
663 // (1 << CP0MVPC0_TCA) | (0x1 << CP0MVPC0_PVPE) |
664 // (0x04 << CP0MVPC0_PTC);
665 (1 << CP0MVPC0_TCA) | (0x0 << CP0MVPC0_PVPE) |
666 (0x00 << CP0MVPC0_PTC);
667 #if !defined(CONFIG_USER_ONLY)
668 /* Usermode has no TLB support */
669 env->mvp->CP0_MVPConf0 |= (env->tlb->nb_tlb << CP0MVPC0_PTLBE);
672 /* Allocatable CP1 have media extensions, allocatable CP1 have FP support,
673 no UDI implemented, no CP2 implemented, 1 CP1 implemented. */
674 env->mvp->CP0_MVPConf1 = (1 << CP0MVPC1_CIM) | (1 << CP0MVPC1_CIF) |
675 (0x0 << CP0MVPC1_PCX) | (0x0 << CP0MVPC1_PCP2) |
676 (0x1 << CP0MVPC1_PCP1);