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.1 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 ((1U << 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 #define MIPS_CONFIG5 \
54 /*****************************************************************************/
55 /* MIPS CPU definitions */
56 const mips_def_t mips_defs[] =
60 .CP0_PRid = 0x00018000,
61 .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_R4000 << CP0C0_MT),
62 .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
63 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
64 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
66 .CP0_Config2 = MIPS_CONFIG2,
67 .CP0_Config3 = MIPS_CONFIG3,
68 .CP0_LLAddr_rw_bitmask = 0,
69 .CP0_LLAddr_shift = 4,
72 .CP0_Status_rw_bitmask = 0x1278FF17,
75 .insn_flags = CPU_MIPS32R1,
76 .mmu_type = MMU_TYPE_R4000,
80 .CP0_PRid = 0x00018300,
81 /* Config1 implemented, fixed mapping MMU,
82 no virtual icache, uncached coherency. */
83 .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_FMT << CP0C0_MT),
84 .CP0_Config1 = MIPS_CONFIG1 |
85 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
86 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
88 .CP0_Config2 = MIPS_CONFIG2,
89 .CP0_Config3 = MIPS_CONFIG3,
90 .CP0_LLAddr_rw_bitmask = 0,
91 .CP0_LLAddr_shift = 4,
94 .CP0_Status_rw_bitmask = 0x1258FF17,
97 .insn_flags = CPU_MIPS32R1 | ASE_MIPS16,
98 .mmu_type = MMU_TYPE_FMT,
102 .CP0_PRid = 0x00018400,
103 .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_R4000 << CP0C0_MT),
104 .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
105 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
106 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
108 .CP0_Config2 = MIPS_CONFIG2,
109 .CP0_Config3 = MIPS_CONFIG3,
110 .CP0_LLAddr_rw_bitmask = 0,
111 .CP0_LLAddr_shift = 4,
114 .CP0_Status_rw_bitmask = 0x1278FF17,
117 .insn_flags = CPU_MIPS32R1,
118 .mmu_type = MMU_TYPE_R4000,
122 .CP0_PRid = 0x1ed0024f,
123 .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_R4000 << CP0C0_MT),
124 .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
125 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
126 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
128 .CP0_Config2 = MIPS_CONFIG2,
129 .CP0_Config3 = MIPS_CONFIG3,
130 .CP0_LLAddr_rw_bitmask = 0,
131 .CP0_LLAddr_shift = 4,
134 .CP0_Status_rw_bitmask = 0x1278FF17,
137 .insn_flags = CPU_MIPS32R1 | ASE_MXU,
138 .mmu_type = MMU_TYPE_R4000,
142 .CP0_PRid = 0x00018500,
143 .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_FMT << CP0C0_MT),
144 .CP0_Config1 = MIPS_CONFIG1 |
145 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
146 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
148 .CP0_Config2 = MIPS_CONFIG2,
149 .CP0_Config3 = MIPS_CONFIG3,
150 .CP0_LLAddr_rw_bitmask = 0,
151 .CP0_LLAddr_shift = 4,
154 .CP0_Status_rw_bitmask = 0x1258FF17,
157 .insn_flags = CPU_MIPS32R1 | ASE_MIPS16,
158 .mmu_type = MMU_TYPE_FMT,
162 .CP0_PRid = 0x00019000,
163 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
164 (MMU_TYPE_R4000 << CP0C0_MT),
165 .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
166 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
167 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
169 .CP0_Config2 = MIPS_CONFIG2,
170 .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
171 .CP0_LLAddr_rw_bitmask = 0,
172 .CP0_LLAddr_shift = 4,
175 .CP0_Status_rw_bitmask = 0x1278FF17,
178 .insn_flags = CPU_MIPS32R2,
179 .mmu_type = MMU_TYPE_R4000,
183 .CP0_PRid = 0x00019100,
184 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
185 (MMU_TYPE_FMT << CP0C0_MT),
186 .CP0_Config1 = MIPS_CONFIG1 |
187 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
188 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
190 .CP0_Config2 = MIPS_CONFIG2,
191 .CP0_Config3 = MIPS_CONFIG3,
192 .CP0_LLAddr_rw_bitmask = 0,
193 .CP0_LLAddr_shift = 4,
196 .CP0_Status_rw_bitmask = 0x1258FF17,
199 .insn_flags = CPU_MIPS32R2 | ASE_MIPS16,
200 .mmu_type = MMU_TYPE_FMT,
204 .CP0_PRid = 0x00019300,
205 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
206 (MMU_TYPE_R4000 << CP0C0_MT),
207 .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
208 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
209 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
211 .CP0_Config2 = MIPS_CONFIG2,
212 .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
213 .CP0_LLAddr_rw_bitmask = 0,
214 .CP0_LLAddr_shift = 4,
217 /* No DSP implemented. */
218 .CP0_Status_rw_bitmask = 0x1278FF1F,
221 .insn_flags = CPU_MIPS32R2 | ASE_MIPS16,
222 .mmu_type = MMU_TYPE_R4000,
226 .CP0_PRid = 0x00019600,
227 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
228 (MMU_TYPE_R4000 << CP0C0_MT),
229 .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
230 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
231 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
233 .CP0_Config2 = MIPS_CONFIG2,
234 .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_DSPP) | (0 << CP0C3_VInt),
235 .CP0_LLAddr_rw_bitmask = 0,
236 .CP0_LLAddr_shift = 4,
239 /* we have a DSP, but no FPU */
240 .CP0_Status_rw_bitmask = 0x1378FF1F,
243 .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP,
244 .mmu_type = MMU_TYPE_R4000,
248 .CP0_PRid = 0x00019300,
249 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
250 (MMU_TYPE_R4000 << CP0C0_MT),
251 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
252 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
253 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
255 .CP0_Config2 = MIPS_CONFIG2,
256 .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
257 .CP0_LLAddr_rw_bitmask = 0,
258 .CP0_LLAddr_shift = 4,
261 /* No DSP implemented. */
262 .CP0_Status_rw_bitmask = 0x3678FF1F,
263 .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
264 (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID),
266 .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
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) | (63 << 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),
298 .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
299 .CP0_SRSCtl = (0xf << CP0SRSCtl_HSS),
300 .CP0_SRSConf0_rw_bitmask = 0x3fffffff,
301 .CP0_SRSConf0 = (1U << CP0SRSC0_M) | (0x3fe << CP0SRSC0_SRS3) |
302 (0x3fe << CP0SRSC0_SRS2) | (0x3fe << CP0SRSC0_SRS1),
303 .CP0_SRSConf1_rw_bitmask = 0x3fffffff,
304 .CP0_SRSConf1 = (1U << CP0SRSC1_M) | (0x3fe << CP0SRSC1_SRS6) |
305 (0x3fe << CP0SRSC1_SRS5) | (0x3fe << CP0SRSC1_SRS4),
306 .CP0_SRSConf2_rw_bitmask = 0x3fffffff,
307 .CP0_SRSConf2 = (1U << CP0SRSC2_M) | (0x3fe << CP0SRSC2_SRS9) |
308 (0x3fe << CP0SRSC2_SRS8) | (0x3fe << CP0SRSC2_SRS7),
309 .CP0_SRSConf3_rw_bitmask = 0x3fffffff,
310 .CP0_SRSConf3 = (1U << CP0SRSC3_M) | (0x3fe << CP0SRSC3_SRS12) |
311 (0x3fe << CP0SRSC3_SRS11) | (0x3fe << CP0SRSC3_SRS10),
312 .CP0_SRSConf4_rw_bitmask = 0x3fffffff,
313 .CP0_SRSConf4 = (0x3fe << CP0SRSC4_SRS15) |
314 (0x3fe << CP0SRSC4_SRS14) | (0x3fe << CP0SRSC4_SRS13),
317 .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_MT,
318 .mmu_type = MMU_TYPE_R4000,
322 .CP0_PRid = 0x00019700,
323 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
324 (MMU_TYPE_R4000 << CP0C0_MT),
325 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
326 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
327 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
329 .CP0_Config2 = MIPS_CONFIG2,
330 .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_DSP2P) | (1 << CP0C3_DSPP) |
332 .CP0_LLAddr_rw_bitmask = 0,
333 .CP0_LLAddr_shift = 4,
336 .CP0_Status_rw_bitmask = 0x3778FF1F,
337 .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
338 (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID),
340 .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
343 .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_DSP_R2,
344 .mmu_type = MMU_TYPE_R4000,
348 .CP0_PRid = 0x2ed1024f,
349 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
350 (MMU_TYPE_R4000 << CP0C0_MT),
351 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
352 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
353 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
355 .CP0_Config2 = MIPS_CONFIG2,
356 .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_DSP2P) | (1 << CP0C3_DSPP) |
358 .CP0_LLAddr_rw_bitmask = 0,
359 .CP0_LLAddr_shift = 4,
362 .CP0_Status_rw_bitmask = 0x3778FF1F,
363 .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
364 (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID),
366 .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
369 .insn_flags = CPU_MIPS32R2 | ASE_MXU,
370 .mmu_type = MMU_TYPE_R4000,
374 .CP0_PRid = 0x00019b00,
375 /* Config1 implemented, fixed mapping MMU,
376 no virtual icache, uncached coherency. */
377 .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_KU) | (0x2 << CP0C0_K23) |
378 (0x1 << CP0C0_AR) | (MMU_TYPE_FMT << CP0C0_MT),
379 .CP0_Config1 = MIPS_CONFIG1,
380 .CP0_Config2 = MIPS_CONFIG2,
381 .CP0_Config3 = MIPS_CONFIG3 | (0x2 << CP0C3_ISA) | (1 << CP0C3_VInt) |
383 .CP0_Config4 = MIPS_CONFIG4 | (1 << CP0C4_M),
384 .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_NFExists),
385 .CP0_Config7 = 1 << CP0C7_WII,
386 .CP0_LLAddr_rw_bitmask = 0,
387 .CP0_LLAddr_shift = 4,
390 .CP0_Status_rw_bitmask = 0x1258FF17,
393 .insn_flags = CPU_MIPS32R2 | ASE_MICROMIPS,
394 .mmu_type = MMU_TYPE_FMT,
398 /* This is the TLB-based MMU core. */
399 .CP0_PRid = 0x00019c00,
400 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
401 (MMU_TYPE_R4000 << CP0C0_MT),
402 .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
403 (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
404 (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA),
405 .CP0_Config2 = MIPS_CONFIG2,
406 .CP0_Config3 = MIPS_CONFIG3 | (0x2 << CP0C3_ISA) | (0 << CP0C3_VInt) |
408 .CP0_Config4 = MIPS_CONFIG4 | (1 << CP0C4_M),
409 .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_NFExists),
410 .CP0_Config7 = 1 << CP0C7_WII,
411 .CP0_LLAddr_rw_bitmask = 0,
412 .CP0_LLAddr_shift = 4,
415 .CP0_Status_rw_bitmask = 0x1278FF17,
418 .insn_flags = CPU_MIPS32R2 | ASE_MICROMIPS,
419 .mmu_type = MMU_TYPE_R4000,
423 * Config3: VZ, CTXTC, CDMM, TL
428 .CP0_PRid = 0x0001A800,
429 .CP0_Config0 = MIPS_CONFIG0 | (1 << CP0C0_MM) | (1 << CP0C0_AR) |
430 (MMU_TYPE_R4000 << CP0C0_MT),
431 .CP0_Config1 = MIPS_CONFIG1 | (0x3F << CP0C1_MMU) |
432 (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
433 (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
434 (1 << CP0C1_PC) | (1 << CP0C1_FP),
435 .CP0_Config2 = MIPS_CONFIG2,
436 .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) |
437 (1 << CP0C3_CMGCR) | (1 << CP0C3_MSAP) |
438 (1 << CP0C3_BP) | (1 << CP0C3_BI) | (1 << CP0C3_SC) |
439 (1 << CP0C3_PW) | (1 << CP0C3_ULRI) | (1 << CP0C3_RXI) |
440 (1 << CP0C3_LPA) | (1 << CP0C3_VInt),
441 .CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | (2 << CP0C4_IE) |
442 (0x1c << CP0C4_KScrExist),
443 .CP0_Config4_rw_bitmask = 0,
444 .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_EVA) | (1 << CP0C5_MVH) |
445 (1 << CP0C5_LLB) | (1 << CP0C5_MRP),
446 .CP0_Config5_rw_bitmask = (1 << CP0C5_K) | (1 << CP0C5_CV) |
447 (1 << CP0C5_MSAEn) | (1 << CP0C5_UFE) |
448 (1 << CP0C5_FRE) | (1 << CP0C5_UFR),
449 .CP0_Config7 = 1 << CP0C7_WII,
450 .CP0_LLAddr_rw_bitmask = 0,
451 .CP0_LLAddr_shift = 0,
454 .CP0_Status_rw_bitmask = 0x3C68FF1F,
455 .CP0_PageGrain_rw_bitmask = (1U << CP0PG_RIE) | (1 << CP0PG_XIE) |
456 (1 << CP0PG_ELPA) | (1 << CP0PG_IEC),
457 .CP0_EBaseWG_rw_bitmask = (1 << CP0EBase_WG),
458 .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_UFRP) | (1 << FCR0_HAS2008) |
459 (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
460 (1 << FCR0_D) | (1 << FCR0_S) | (0x03 << FCR0_PRID),
461 .CP1_fcr31 = (1 << FCR31_ABS2008) | (1 << FCR31_NAN2008),
462 .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
465 .insn_flags = CPU_MIPS32R5,
466 .mmu_type = MMU_TYPE_R4000,
469 /* A generic CPU supporting MIPS32 Release 6 ISA.
470 FIXME: Support IEEE 754-2008 FP.
471 Eventually this should be replaced by a real CPU model. */
472 .name = "mips32r6-generic",
473 .CP0_PRid = 0x00010000,
474 .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AR) |
475 (MMU_TYPE_R4000 << CP0C0_MT),
476 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (31 << CP0C1_MMU) |
477 (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
478 (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
479 (0 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
480 .CP0_Config2 = MIPS_CONFIG2,
481 .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_BP) | (1 << CP0C3_BI) |
482 (2 << CP0C3_ISA) | (1 << CP0C3_ULRI) |
483 (1 << CP0C3_RXI) | (1U << CP0C3_M),
484 .CP0_Config4 = MIPS_CONFIG4 | (0xfc << CP0C4_KScrExist) |
485 (3 << CP0C4_IE) | (1U << CP0C4_M),
486 .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_XNP) | (1 << CP0C5_LLB),
487 .CP0_Config5_rw_bitmask = (1 << CP0C5_SBRI) | (1 << CP0C5_FRE) |
489 .CP0_LLAddr_rw_bitmask = 0,
490 .CP0_LLAddr_shift = 0,
493 .CP0_Status_rw_bitmask = 0x3058FF1F,
494 .CP0_PageGrain = (1 << CP0PG_IEC) | (1 << CP0PG_XIE) |
496 .CP0_PageGrain_rw_bitmask = 0,
497 .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_HAS2008) | (1 << FCR0_F64) |
498 (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
499 (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV),
500 .CP1_fcr31 = (1 << FCR31_ABS2008) | (1 << FCR31_NAN2008),
501 .CP1_fcr31_rw_bitmask = 0x0103FFFF,
504 .insn_flags = CPU_MIPS32R6 | ASE_MICROMIPS,
505 .mmu_type = MMU_TYPE_R4000,
509 .CP0_PRid = 0x00010000,
510 .CP0_Config0 = MIPS_CONFIG0 | (1 << CP0C0_MM) | (0x2 << CP0C0_AR) |
511 (MMU_TYPE_R4000 << CP0C0_MT),
512 .CP0_Config1 = (1U << CP0C1_M) | (15 << CP0C1_MMU) | (2 << CP0C1_IS) |
513 (4 << CP0C1_IL) | (3 << CP0C1_IA) | (2 << CP0C1_DS) |
514 (4 << CP0C1_DL) | (3 << CP0C1_DA) | (1 << CP0C1_PC) |
516 .CP0_Config2 = MIPS_CONFIG2,
517 .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) | (1 << CP0C3_CMGCR) |
518 (1 << CP0C3_BI) | (1 << CP0C3_SC) | (3 << CP0C3_MMAR) |
519 (1 << CP0C3_ISA_ON_EXC) | (1 << CP0C3_ISA) |
520 (1 << CP0C3_ULRI) | (1 << CP0C3_RXI) |
521 (1 << CP0C3_DSP2P) | (1 << CP0C3_DSPP) |
522 (1 << CP0C3_CTXTC) | (1 << CP0C3_VInt) |
523 (1 << CP0C3_CDMM) | (1 << CP0C3_MT) | (1 << CP0C3_TL),
524 .CP0_Config4 = MIPS_CONFIG4 | (0xfc << CP0C4_KScrExist) |
525 (2 << CP0C4_IE) | (1U << CP0C4_M),
526 .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_MVH) | (1 << CP0C5_LLB),
527 .CP0_Config5_rw_bitmask = (1 << CP0C5_SBRI) | (1 << CP0C5_FRE) |
529 .CP0_LLAddr_rw_bitmask = 0,
530 .CP0_LLAddr_shift = 0,
533 .CP0_Status_rw_bitmask = 0x3158FF1F,
534 .CP0_PageGrain = (1 << CP0PG_IEC) | (1 << CP0PG_XIE) |
536 .CP0_PageGrain_rw_bitmask = 0,
537 .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_HAS2008) | (1 << FCR0_F64) |
538 (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
539 (1 << FCR0_S) | (0x02 << FCR0_PRID) | (0x0 << FCR0_REV),
540 .CP1_fcr31 = (1 << FCR31_ABS2008) | (1 << FCR31_NAN2008),
543 .insn_flags = CPU_MIPS32R6 | ISA_NANOMIPS32 |
544 ASE_DSP | ASE_DSP_R2 | ASE_DSP_R3 | ASE_MT,
545 .mmu_type = MMU_TYPE_R4000,
547 #if defined(TARGET_MIPS64)
550 .CP0_PRid = 0x00000400,
551 /* No L2 cache, icache size 8k, dcache size 8k, uncached coherency. */
552 .CP0_Config0 = (2 << CP0C0_Impl) | (1 << CP0C0_IC) | (1 << CP0C0_DC) |
554 /* Note: Config1 is only used internally, the R4000 has only Config0. */
555 .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
556 .CP0_LLAddr_rw_bitmask = 0xFFFFFFFF,
557 .CP0_LLAddr_shift = 4,
560 .CP0_Status_rw_bitmask = 0x3678FFFF,
561 /* The R4000 has a full 64bit FPU but doesn't use the fcr0 bits. */
562 .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x0 << FCR0_REV),
564 .CP1_fcr31_rw_bitmask = 0x0183FFFF,
567 .insn_flags = CPU_MIPS3,
568 .mmu_type = MMU_TYPE_R4000,
572 .CP0_PRid = 0x00005400,
573 /* No L2 cache, icache size 8k, dcache size 8k, uncached coherency. */
574 .CP0_Config0 = (2 << CP0C0_Impl) | (1 << CP0C0_IC) | (1 << CP0C0_DC) |
576 .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
577 .CP0_LLAddr_rw_bitmask = 0xFFFFFFFFL,
578 .CP0_LLAddr_shift = 4,
581 .CP0_Status_rw_bitmask = 0x3678FFFF,
582 /* The VR5432 has a full 64bit FPU but doesn't use the fcr0 bits. */
583 .CP1_fcr0 = (0x54 << FCR0_PRID) | (0x0 << FCR0_REV),
585 .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
588 .insn_flags = CPU_MIPS4 | INSN_VR54XX,
589 .mmu_type = MMU_TYPE_R4000,
593 .CP0_PRid = 0x00018100,
594 .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) |
595 (MMU_TYPE_R4000 << CP0C0_MT),
596 .CP0_Config1 = MIPS_CONFIG1 | (31 << CP0C1_MMU) |
597 (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) |
598 (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) |
599 (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
600 .CP0_Config2 = MIPS_CONFIG2,
601 .CP0_Config3 = MIPS_CONFIG3,
602 .CP0_LLAddr_rw_bitmask = 0,
603 .CP0_LLAddr_shift = 4,
606 .CP0_Status_rw_bitmask = 0x12F8FFFF,
609 .insn_flags = CPU_MIPS64R1,
610 .mmu_type = MMU_TYPE_R4000,
614 .CP0_PRid = 0x00018100,
615 .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) |
616 (MMU_TYPE_R4000 << CP0C0_MT),
617 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (31 << CP0C1_MMU) |
618 (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) |
619 (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) |
620 (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
621 .CP0_Config2 = MIPS_CONFIG2,
622 .CP0_Config3 = MIPS_CONFIG3,
623 .CP0_LLAddr_rw_bitmask = 0,
624 .CP0_LLAddr_shift = 4,
627 .CP0_Status_rw_bitmask = 0x36F8FFFF,
628 /* The 5Kf has F64 / L / W but doesn't use the fcr0 bits. */
629 .CP1_fcr0 = (1 << FCR0_D) | (1 << FCR0_S) |
630 (0x81 << FCR0_PRID) | (0x0 << FCR0_REV),
632 .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
635 .insn_flags = CPU_MIPS64R1,
636 .mmu_type = MMU_TYPE_R4000,
640 /* We emulate a later version of the 20Kc, earlier ones had a broken
642 .CP0_PRid = 0x000182a0,
643 .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) |
644 (MMU_TYPE_R4000 << CP0C0_MT) | (1 << CP0C0_VI),
645 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (47 << CP0C1_MMU) |
646 (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
647 (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
648 (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
649 .CP0_Config2 = MIPS_CONFIG2,
650 .CP0_Config3 = MIPS_CONFIG3,
651 .CP0_LLAddr_rw_bitmask = 0,
652 .CP0_LLAddr_shift = 0,
655 .CP0_Status_rw_bitmask = 0x36FBFFFF,
656 /* The 20Kc has F64 / L / W but doesn't use the fcr0 bits. */
657 .CP1_fcr0 = (1 << FCR0_3D) | (1 << FCR0_PS) |
658 (1 << FCR0_D) | (1 << FCR0_S) |
659 (0x82 << FCR0_PRID) | (0x0 << FCR0_REV),
661 .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
664 .insn_flags = CPU_MIPS64R1 | ASE_MIPS3D,
665 .mmu_type = MMU_TYPE_R4000,
668 /* A generic CPU providing MIPS64 Release 2 features.
669 FIXME: Eventually this should be replaced by a real CPU model. */
670 .name = "MIPS64R2-generic",
671 .CP0_PRid = 0x00010000,
672 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
673 (MMU_TYPE_R4000 << CP0C0_MT),
674 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) |
675 (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
676 (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
677 (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
678 .CP0_Config2 = MIPS_CONFIG2,
679 .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA),
680 .CP0_LLAddr_rw_bitmask = 0,
681 .CP0_LLAddr_shift = 0,
684 .CP0_Status_rw_bitmask = 0x36FBFFFF,
685 .CP0_EBaseWG_rw_bitmask = (1 << CP0EBase_WG),
686 .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_3D) | (1 << FCR0_PS) |
687 (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
688 (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV),
690 .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
693 .insn_flags = CPU_MIPS64R2 | ASE_MIPS3D,
694 .mmu_type = MMU_TYPE_R4000,
698 .CP0_PRid = 0x00018900,
699 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
700 (MMU_TYPE_R4000 << CP0C0_MT),
701 .CP0_Config1 = MIPS_CONFIG1 | (31 << CP0C1_MMU) |
702 (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) |
703 (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) |
704 (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
705 .CP0_Config2 = MIPS_CONFIG2,
706 .CP0_Config3 = MIPS_CONFIG3,
707 .CP0_LLAddr_rw_bitmask = 0,
708 .CP0_LLAddr_shift = 4,
711 .CP0_Status_rw_bitmask = 0x12F8FFFF,
714 .insn_flags = CPU_MIPS64R2,
715 .mmu_type = MMU_TYPE_R4000,
719 .CP0_PRid = 0x00018900,
720 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
721 (MMU_TYPE_R4000 << CP0C0_MT),
722 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (31 << CP0C1_MMU) |
723 (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) |
724 (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) |
725 (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
726 .CP0_Config2 = MIPS_CONFIG2,
727 .CP0_Config3 = MIPS_CONFIG3,
728 .CP0_LLAddr_rw_bitmask = 0,
729 .CP0_LLAddr_shift = 4,
732 .CP0_Status_rw_bitmask = 0x36F8FFFF,
733 .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
734 (1 << FCR0_D) | (1 << FCR0_S) |
735 (0x89 << FCR0_PRID) | (0x0 << FCR0_REV),
738 .insn_flags = CPU_MIPS64R2,
739 .mmu_type = MMU_TYPE_R4000,
744 .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AR) | (0x2 << CP0C0_AT) |
745 (MMU_TYPE_R4000 << CP0C0_MT),
746 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
747 (2 << CP0C1_IS) | (5 << CP0C1_IL) | (3 << CP0C1_IA) |
748 (2 << CP0C1_DS) | (5 << CP0C1_DL) | (3 << CP0C1_DA) |
749 (0 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
750 .CP0_Config2 = MIPS_CONFIG2,
751 .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) |
752 (1 << CP0C3_CMGCR) | (1 << CP0C3_MSAP) |
753 (1 << CP0C3_BP) | (1 << CP0C3_BI) | (1 << CP0C3_ULRI) |
754 (1 << CP0C3_RXI) | (1 << CP0C3_LPA) | (1 << CP0C3_VInt),
755 .CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | (3 << CP0C4_IE) |
756 (1 << CP0C4_AE) | (0xfc << CP0C4_KScrExist),
757 .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_XNP) | (1 << CP0C5_VP) |
758 (1 << CP0C5_LLB) | (1 << CP0C5_MRP) | (3 << CP0C5_GI),
759 .CP0_Config5_rw_bitmask = (1 << CP0C5_MSAEn) | (1 << CP0C5_SBRI) |
760 (1 << CP0C5_FRE) | (1 << CP0C5_UFE),
761 .CP0_LLAddr_rw_bitmask = 0,
762 .CP0_LLAddr_shift = 0,
765 .CP0_Status_rw_bitmask = 0x30D8FFFF,
766 .CP0_PageGrain = (1 << CP0PG_IEC) | (1 << CP0PG_XIE) |
768 .CP0_PageGrain_rw_bitmask = (1 << CP0PG_ELPA),
769 .CP0_EBaseWG_rw_bitmask = (1 << CP0EBase_WG),
770 .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_HAS2008) | (1 << FCR0_F64) |
771 (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
772 (1 << FCR0_S) | (0x03 << FCR0_PRID) | (0x0 << FCR0_REV),
773 .CP1_fcr31 = (1 << FCR31_ABS2008) | (1 << FCR31_NAN2008),
774 .CP1_fcr31_rw_bitmask = 0x0103FFFF,
775 .MSAIR = 0x03 << MSAIR_ProcID,
778 .insn_flags = CPU_MIPS64R6,
779 .mmu_type = MMU_TYPE_R4000,
784 .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AR) | (0x2 << CP0C0_AT) |
785 (MMU_TYPE_R4000 << CP0C0_MT),
786 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
787 (2 << CP0C1_IS) | (5 << CP0C1_IL) | (3 << CP0C1_IA) |
788 (2 << CP0C1_DS) | (5 << CP0C1_DL) | (3 << CP0C1_DA) |
789 (0 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
790 .CP0_Config2 = MIPS_CONFIG2,
791 .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) |
792 (1 << CP0C3_CMGCR) | (1 << CP0C3_MSAP) |
793 (1 << CP0C3_BP) | (1 << CP0C3_BI) | (1 << CP0C3_ULRI) |
794 (1 << CP0C3_RXI) | (1 << CP0C3_LPA) | (1 << CP0C3_VInt),
795 .CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | (3 << CP0C4_IE) |
796 (1 << CP0C4_AE) | (0xfc << CP0C4_KScrExist),
797 .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_XNP) | (1 << CP0C5_VP) |
798 (1 << CP0C5_LLB) | (1 << CP0C5_MRP) | (3 << CP0C5_GI),
799 .CP0_Config5_rw_bitmask = (1 << CP0C5_MSAEn) | (1 << CP0C5_SBRI) |
800 (1 << CP0C5_FRE) | (1 << CP0C5_UFE),
801 .CP0_LLAddr_rw_bitmask = 0,
802 .CP0_LLAddr_shift = 0,
805 .CP0_Status_rw_bitmask = 0x30D8FFFF,
806 .CP0_PageGrain = (1 << CP0PG_IEC) | (1 << CP0PG_XIE) |
808 .CP0_PageGrain_rw_bitmask = (1 << CP0PG_ELPA),
809 .CP0_EBaseWG_rw_bitmask = (1 << CP0EBase_WG),
810 .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_HAS2008) | (1 << FCR0_F64) |
811 (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
812 (1 << FCR0_S) | (0x03 << FCR0_PRID) | (0x0 << FCR0_REV),
813 .CP1_fcr31 = (1 << FCR31_ABS2008) | (1 << FCR31_NAN2008),
814 .CP1_fcr31_rw_bitmask = 0x0103FFFF,
815 .MSAIR = 0x03 << MSAIR_ProcID,
818 .insn_flags = CPU_MIPS64R6,
819 .mmu_type = MMU_TYPE_R4000,
822 .name = "Loongson-2E",
824 /* 64KB I-cache and d-cache. 4 way with 32 bit cache line size. */
825 .CP0_Config0 = (3 << CP0C0_Impl) | (4 << CP0C0_IC) | (4 << CP0C0_DC) |
826 (1 << CP0C0_IB) | (1 << CP0C0_DB) | (0x2 << CP0C0_K0),
827 /* Note: Config1 is only used internally,
828 Loongson-2E has only Config0. */
829 .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
832 .CP0_Status_rw_bitmask = 0x35D0FFFF,
833 .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x1 << FCR0_REV),
835 .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
838 .insn_flags = CPU_MIPS3 | INSN_LOONGSON2E,
839 .mmu_type = MMU_TYPE_R4000,
842 .name = "Loongson-2F",
844 /* 64KB I-cache and d-cache. 4 way with 32 bit cache line size. */
845 .CP0_Config0 = (3 << CP0C0_Impl) | (4 << CP0C0_IC) | (4 << CP0C0_DC) |
846 (1 << CP0C0_IB) | (1 << CP0C0_DB) | (0x2 << CP0C0_K0),
847 /* Note: Config1 is only used internally,
848 Loongson-2F has only Config0. */
849 .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
852 .CP0_Status_rw_bitmask = 0xF5D0FF1F, /* Bits 7:5 not writable. */
853 .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x1 << FCR0_REV),
855 .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
858 .insn_flags = CPU_MIPS3 | INSN_LOONGSON2F | ASE_LMMI,
859 .mmu_type = MMU_TYPE_R4000,
862 .name = "Loongson-3A1000", /* Loongson-3A R1, GS464-based */
864 /* 64KB I-cache and d-cache. 4 way with 32 bit cache line size. */
865 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
866 (MMU_TYPE_R4000 << CP0C0_MT),
867 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) |
868 (3 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
869 (3 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
870 (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
871 .CP0_Config2 = MIPS_CONFIG2 | (7 << CP0C2_SS) | (4 << CP0C2_SL) |
873 .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA),
874 .CP0_LLAddr_rw_bitmask = 0,
877 .CP0_Status_rw_bitmask = 0x74D8FFFF,
878 .CP0_PageGrain = (1 << CP0PG_ELPA),
879 .CP0_PageGrain_rw_bitmask = (1 << CP0PG_ELPA),
880 .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x1 << FCR0_REV) | (0x1 << FCR0_F64) |
881 (0x1 << FCR0_PS) | (0x1 << FCR0_L) | (0x1 << FCR0_W) |
882 (0x1 << FCR0_D) | (0x1 << FCR0_S),
884 .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
887 .insn_flags = CPU_MIPS64R2 | INSN_LOONGSON3A |
889 .mmu_type = MMU_TYPE_R4000,
892 .name = "Loongson-3A4000", /* Loongson-3A R4, GS464V-based */
893 .CP0_PRid = 0x14C000,
894 /* 64KB I-cache and d-cache. 4 way with 32 bit cache line size. */
895 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
896 (MMU_TYPE_R4000 << CP0C0_MT),
897 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) |
898 (2 << CP0C1_IS) | (5 << CP0C1_IL) | (3 << CP0C1_IA) |
899 (2 << CP0C1_DS) | (5 << CP0C1_DL) | (3 << CP0C1_DA) |
900 (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
901 .CP0_Config2 = MIPS_CONFIG2 | (5 << CP0C2_SS) | (5 << CP0C2_SL) |
903 .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) | (1 << CP0C3_MSAP) |
904 (1 << CP0C3_BP) | (1 << CP0C3_BI) | (1 << CP0C3_ULRI) |
905 (1 << CP0C3_RXI) | (1 << CP0C3_LPA) | (1 << CP0C3_VInt),
906 .CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | (2 << CP0C4_IE) |
907 (1 << CP0C4_AE) | (0x1c << CP0C4_KScrExist),
908 .CP0_Config4_rw_bitmask = 0,
909 .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_CRCP) | (1 << CP0C5_NFExists),
910 .CP0_Config5_rw_bitmask = (1 << CP0C5_K) | (1 << CP0C5_CV) |
911 (1 << CP0C5_MSAEn) | (1 << CP0C5_UFE) |
912 (1 << CP0C5_FRE) | (1 << CP0C5_SBRI),
913 .CP0_Config6 = (1 << CP0C6_VCLRU) | (1 << CP0C6_DCLRU) |
914 (1 << CP0C6_SFBEN) | (1 << CP0C6_VLTINT) |
915 (1 << CP0C6_INSTPREF) | (1 << CP0C6_DATAPREF),
916 .CP0_Config6_rw_bitmask = (1 << CP0C6_BPPASS) | (0x3f << CP0C6_KPOS) |
917 (1 << CP0C6_KE) | (1 << CP0C6_VTLBONLY) |
918 (1 << CP0C6_LASX) | (1 << CP0C6_SSEN) |
919 (1 << CP0C6_DISDRTIME) | (1 << CP0C6_PIXNUEN) |
920 (1 << CP0C6_SCRAND) | (1 << CP0C6_LLEXCEN) |
921 (1 << CP0C6_DISVC) | (1 << CP0C6_VCLRU) |
922 (1 << CP0C6_DCLRU) | (1 << CP0C6_PIXUEN) |
923 (1 << CP0C6_DISBLKLYEN) | (1 << CP0C6_UMEMUALEN) |
924 (1 << CP0C6_SFBEN) | (1 << CP0C6_FLTINT) |
925 (1 << CP0C6_VLTINT) | (1 << CP0C6_DISBTB) |
926 (3 << CP0C6_STPREFCTL) | (1 << CP0C6_INSTPREF) |
927 (1 << CP0C6_DATAPREF),
929 .CP0_Config7_rw_bitmask = (1 << CP0C7_NAPCGEN) | (1 << CP0C7_UNIMUEN) |
930 (1 << CP0C7_VFPUCGEN),
931 .CP0_LLAddr_rw_bitmask = 1,
934 .CP0_Status_rw_bitmask = 0x7DDBFFFF,
935 .CP0_PageGrain = (1 << CP0PG_ELPA),
936 .CP0_PageGrain_rw_bitmask = (1U << CP0PG_RIE) | (1 << CP0PG_XIE) |
937 (1 << CP0PG_ELPA) | (1 << CP0PG_IEC),
938 .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x1 << FCR0_REV) | (0x1 << FCR0_F64) |
939 (0x1 << FCR0_PS) | (0x1 << FCR0_L) | (0x1 << FCR0_W) |
940 (0x1 << FCR0_D) | (0x1 << FCR0_S),
942 .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
943 .MSAIR = (0x01 << MSAIR_ProcID) | (0x40 << MSAIR_Rev),
944 .lcsr_cpucfg1 = (1 << CPUCFG1_FP) | (2 << CPUCFG1_FPREV) |
945 (1 << CPUCFG1_MSA1) | (1 << CPUCFG1_LSLDR0) |
946 (1 << CPUCFG1_LSPERF) | (1 << CPUCFG1_LSPERFX) |
947 (1 << CPUCFG1_LSSYNCI) | (1 << CPUCFG1_LLEXC) |
948 (1 << CPUCFG1_SCRAND) | (1 << CPUCFG1_MUALP) |
949 (1 << CPUCFG1_KMUALEN) | (1 << CPUCFG1_ITLBT) |
950 (1 << CPUCFG1_SFBP) | (1 << CPUCFG1_CDMAP),
951 .lcsr_cpucfg2 = (1 << CPUCFG2_LEXT1) | (1 << CPUCFG2_LCSRP) |
952 (1 << CPUCFG2_LDISBLIKELY),
955 .insn_flags = CPU_MIPS64R2 | INSN_LOONGSON3A |
957 .mmu_type = MMU_TYPE_R4000,
960 /* A generic CPU providing MIPS64 DSP R2 ASE features.
961 FIXME: Eventually this should be replaced by a real CPU model. */
962 .name = "mips64dspr2",
963 .CP0_PRid = 0x00010000,
964 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
965 (MMU_TYPE_R4000 << CP0C0_MT),
966 .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) |
967 (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
968 (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
969 (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
970 .CP0_Config2 = MIPS_CONFIG2,
971 .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) | (1 << CP0C3_DSP2P) |
972 (1 << CP0C3_DSPP) | (1 << CP0C3_LPA),
973 .CP0_LLAddr_rw_bitmask = 0,
974 .CP0_LLAddr_shift = 0,
977 .CP0_Status_rw_bitmask = 0x37FBFFFF,
978 .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_3D) | (1 << FCR0_PS) |
979 (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
980 (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV),
982 .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
985 .insn_flags = CPU_MIPS64R2 | ASE_DSP | ASE_DSP_R2,
986 .mmu_type = MMU_TYPE_R4000,
990 * Octeon 68xx with MIPS64 Cavium Octeon features.
992 .name = "Octeon68XX",
993 .CP0_PRid = 0x000D9100,
994 .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
995 (MMU_TYPE_R4000 << CP0C0_MT),
996 .CP0_Config1 = MIPS_CONFIG1 | (0x3F << CP0C1_MMU) |
997 (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) |
998 (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) |
999 (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
1000 .CP0_Config2 = MIPS_CONFIG2,
1001 .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA),
1002 .CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) |
1003 (0x3c << CP0C4_KScrExist) | (1U << CP0C4_MMUExtDef) |
1004 (3U << CP0C4_MMUSizeExt),
1005 .CP0_LLAddr_rw_bitmask = 0,
1006 .CP0_LLAddr_shift = 4,
1007 .CP0_PageGrain = (1 << CP0PG_ELPA),
1010 .CP0_Status_rw_bitmask = 0x12F8FFFF,
1013 .insn_flags = CPU_MIPS64R2 | INSN_OCTEON,
1014 .mmu_type = MMU_TYPE_R4000,
1019 const int mips_defs_number = ARRAY_SIZE(mips_defs);
1021 void mips_cpu_list(void)
1025 for (i = 0; i < ARRAY_SIZE(mips_defs); i++) {
1026 qemu_printf("MIPS '%s'\n", mips_defs[i].name);
1030 static void fpu_init (CPUMIPSState *env, const mips_def_t *def)
1034 for (i = 0; i < MIPS_FPU_MAX; i++)
1035 env->fpus[i].fcr0 = def->CP1_fcr0;
1037 memcpy(&env->active_fpu, &env->fpus[0], sizeof(env->active_fpu));
1040 static void mvp_init(CPUMIPSState *env)
1042 env->mvp = g_malloc0(sizeof(CPUMIPSMVPContext));
1044 if (!ase_mt_available(env)) {
1048 /* MVPConf1 implemented, TLB shareable, no gating storage support,
1049 programmable cache partitioning implemented, number of allocatable
1050 and shareable TLB entries, MVP has allocatable TCs, 2 VPEs
1051 implemented, 5 TCs implemented. */
1052 env->mvp->CP0_MVPConf0 = (1U << CP0MVPC0_M) | (1 << CP0MVPC0_TLBS) |
1053 (0 << CP0MVPC0_GS) | (1 << CP0MVPC0_PCP) |
1054 // TODO: actually do 2 VPEs.
1055 // (1 << CP0MVPC0_TCA) | (0x1 << CP0MVPC0_PVPE) |
1056 // (0x04 << CP0MVPC0_PTC);
1057 (1 << CP0MVPC0_TCA) | (0x0 << CP0MVPC0_PVPE) |
1058 (0x00 << CP0MVPC0_PTC);
1059 #if !defined(CONFIG_USER_ONLY)
1060 /* Usermode has no TLB support */
1061 env->mvp->CP0_MVPConf0 |= (env->tlb->nb_tlb << CP0MVPC0_PTLBE);
1064 /* Allocatable CP1 have media extensions, allocatable CP1 have FP support,
1065 no UDI implemented, no CP2 implemented, 1 CP1 implemented. */
1066 env->mvp->CP0_MVPConf1 = (1U << CP0MVPC1_CIM) | (1 << CP0MVPC1_CIF) |
1067 (0x0 << CP0MVPC1_PCX) | (0x0 << CP0MVPC1_PCP2) |
1068 (0x1 << CP0MVPC1_PCP1);