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 /* MMU types, the first four entries have the same layout as the
69 target_ulong CP0_LLAddr_rw_bitmask
;
73 int32_t CP0_Status_rw_bitmask
;
74 int32_t CP0_TCStatus_rw_bitmask
;
79 int32_t CP0_SRSConf0_rw_bitmask
;
81 int32_t CP0_SRSConf1_rw_bitmask
;
83 int32_t CP0_SRSConf2_rw_bitmask
;
85 int32_t CP0_SRSConf3_rw_bitmask
;
87 int32_t CP0_SRSConf4_rw_bitmask
;
90 enum mips_mmu_types mmu_type
;
93 /*****************************************************************************/
94 /* MIPS CPU definitions */
95 static const mips_def_t mips_defs
[] =
99 .CP0_PRid
= 0x00018000,
100 .CP0_Config0
= MIPS_CONFIG0
| (MMU_TYPE_R4000
<< CP0C0_MT
),
101 .CP0_Config1
= MIPS_CONFIG1
| (15 << CP0C1_MMU
) |
102 (0 << CP0C1_IS
) | (3 << CP0C1_IL
) | (1 << CP0C1_IA
) |
103 (0 << CP0C1_DS
) | (3 << CP0C1_DL
) | (1 << CP0C1_DA
) |
105 .CP0_Config2
= MIPS_CONFIG2
,
106 .CP0_Config3
= MIPS_CONFIG3
,
107 .CP0_LLAddr_rw_bitmask
= 0,
108 .CP0_LLAddr_shift
= 4,
111 .CP0_Status_rw_bitmask
= 0x1278FF17,
114 .insn_flags
= CPU_MIPS32
,
115 .mmu_type
= MMU_TYPE_R4000
,
119 .CP0_PRid
= 0x00018300,
120 /* Config1 implemented, fixed mapping MMU,
121 no virtual icache, uncached coherency. */
122 .CP0_Config0
= MIPS_CONFIG0
| (MMU_TYPE_FMT
<< CP0C0_MT
),
123 .CP0_Config1
= MIPS_CONFIG1
|
124 (0 << CP0C1_IS
) | (3 << CP0C1_IL
) | (1 << CP0C1_IA
) |
125 (0 << CP0C1_DS
) | (3 << CP0C1_DL
) | (1 << CP0C1_DA
) |
127 .CP0_Config2
= MIPS_CONFIG2
,
128 .CP0_Config3
= MIPS_CONFIG3
,
129 .CP0_LLAddr_rw_bitmask
= 0,
130 .CP0_LLAddr_shift
= 4,
133 .CP0_Status_rw_bitmask
= 0x1258FF17,
136 .insn_flags
= CPU_MIPS32
| ASE_MIPS16
,
137 .mmu_type
= MMU_TYPE_FMT
,
141 .CP0_PRid
= 0x00018400,
142 .CP0_Config0
= MIPS_CONFIG0
| (MMU_TYPE_R4000
<< CP0C0_MT
),
143 .CP0_Config1
= MIPS_CONFIG1
| (15 << CP0C1_MMU
) |
144 (0 << CP0C1_IS
) | (3 << CP0C1_IL
) | (1 << CP0C1_IA
) |
145 (0 << CP0C1_DS
) | (3 << CP0C1_DL
) | (1 << CP0C1_DA
) |
147 .CP0_Config2
= MIPS_CONFIG2
,
148 .CP0_Config3
= MIPS_CONFIG3
,
149 .CP0_LLAddr_rw_bitmask
= 0,
150 .CP0_LLAddr_shift
= 4,
153 .CP0_Status_rw_bitmask
= 0x1278FF17,
156 .insn_flags
= CPU_MIPS32
,
157 .mmu_type
= MMU_TYPE_R4000
,
161 .CP0_PRid
= 0x00018500,
162 .CP0_Config0
= MIPS_CONFIG0
| (MMU_TYPE_FMT
<< CP0C0_MT
),
163 .CP0_Config1
= MIPS_CONFIG1
|
164 (0 << CP0C1_IS
) | (3 << CP0C1_IL
) | (1 << CP0C1_IA
) |
165 (0 << CP0C1_DS
) | (3 << CP0C1_DL
) | (1 << CP0C1_DA
) |
167 .CP0_Config2
= MIPS_CONFIG2
,
168 .CP0_Config3
= MIPS_CONFIG3
,
169 .CP0_LLAddr_rw_bitmask
= 0,
170 .CP0_LLAddr_shift
= 4,
173 .CP0_Status_rw_bitmask
= 0x1258FF17,
176 .insn_flags
= CPU_MIPS32
| ASE_MIPS16
,
177 .mmu_type
= MMU_TYPE_FMT
,
181 .CP0_PRid
= 0x00019000,
182 .CP0_Config0
= MIPS_CONFIG0
| (0x1 << CP0C0_AR
) |
183 (MMU_TYPE_R4000
<< CP0C0_MT
),
184 .CP0_Config1
= MIPS_CONFIG1
| (15 << CP0C1_MMU
) |
185 (0 << CP0C1_IS
) | (3 << CP0C1_IL
) | (1 << CP0C1_IA
) |
186 (0 << CP0C1_DS
) | (3 << CP0C1_DL
) | (1 << CP0C1_DA
) |
188 .CP0_Config2
= MIPS_CONFIG2
,
189 .CP0_Config3
= MIPS_CONFIG3
| (0 << CP0C3_VInt
),
190 .CP0_LLAddr_rw_bitmask
= 0,
191 .CP0_LLAddr_shift
= 4,
194 .CP0_Status_rw_bitmask
= 0x1278FF17,
197 .insn_flags
= CPU_MIPS32R2
,
198 .mmu_type
= MMU_TYPE_R4000
,
202 .CP0_PRid
= 0x00019100,
203 .CP0_Config0
= MIPS_CONFIG0
| (0x1 << CP0C0_AR
) |
204 (MMU_TYPE_FMT
<< CP0C0_MT
),
205 .CP0_Config1
= MIPS_CONFIG1
|
206 (0 << CP0C1_IS
) | (3 << CP0C1_IL
) | (1 << CP0C1_IA
) |
207 (0 << CP0C1_DS
) | (3 << CP0C1_DL
) | (1 << CP0C1_DA
) |
209 .CP0_Config2
= MIPS_CONFIG2
,
210 .CP0_Config3
= MIPS_CONFIG3
,
211 .CP0_LLAddr_rw_bitmask
= 0,
212 .CP0_LLAddr_shift
= 4,
215 .CP0_Status_rw_bitmask
= 0x1258FF17,
218 .insn_flags
= CPU_MIPS32R2
| ASE_MIPS16
,
219 .mmu_type
= MMU_TYPE_FMT
,
223 .CP0_PRid
= 0x00019300,
224 .CP0_Config0
= MIPS_CONFIG0
| (0x1 << CP0C0_AR
) |
225 (MMU_TYPE_R4000
<< CP0C0_MT
),
226 .CP0_Config1
= MIPS_CONFIG1
| (15 << CP0C1_MMU
) |
227 (0 << CP0C1_IS
) | (3 << CP0C1_IL
) | (1 << CP0C1_IA
) |
228 (0 << CP0C1_DS
) | (3 << CP0C1_DL
) | (1 << CP0C1_DA
) |
230 .CP0_Config2
= MIPS_CONFIG2
,
231 .CP0_Config3
= MIPS_CONFIG3
| (0 << CP0C3_VInt
),
232 .CP0_LLAddr_rw_bitmask
= 0,
233 .CP0_LLAddr_shift
= 4,
236 /* No DSP implemented. */
237 .CP0_Status_rw_bitmask
= 0x1278FF1F,
240 .insn_flags
= CPU_MIPS32R2
| ASE_MIPS16
,
241 .mmu_type
= MMU_TYPE_R4000
,
245 .CP0_PRid
= 0x00019300,
246 .CP0_Config0
= MIPS_CONFIG0
| (0x1 << CP0C0_AR
) |
247 (MMU_TYPE_R4000
<< CP0C0_MT
),
248 .CP0_Config1
= MIPS_CONFIG1
| (1 << CP0C1_FP
) | (15 << CP0C1_MMU
) |
249 (0 << CP0C1_IS
) | (3 << CP0C1_IL
) | (1 << CP0C1_IA
) |
250 (0 << CP0C1_DS
) | (3 << CP0C1_DL
) | (1 << CP0C1_DA
) |
252 .CP0_Config2
= MIPS_CONFIG2
,
253 .CP0_Config3
= MIPS_CONFIG3
| (0 << CP0C3_VInt
),
254 .CP0_LLAddr_rw_bitmask
= 0,
255 .CP0_LLAddr_shift
= 4,
258 /* No DSP implemented. */
259 .CP0_Status_rw_bitmask
= 0x3678FF1F,
260 .CP1_fcr0
= (1 << FCR0_F64
) | (1 << FCR0_L
) | (1 << FCR0_W
) |
261 (1 << FCR0_D
) | (1 << FCR0_S
) | (0x93 << FCR0_PRID
),
264 .insn_flags
= CPU_MIPS32R2
| ASE_MIPS16
,
265 .mmu_type
= MMU_TYPE_R4000
,
269 .CP0_PRid
= 0x00019500,
270 .CP0_Config0
= MIPS_CONFIG0
| (0x1 << CP0C0_AR
) |
271 (MMU_TYPE_R4000
<< CP0C0_MT
),
272 .CP0_Config1
= MIPS_CONFIG1
| (1 << CP0C1_FP
) | (15 << CP0C1_MMU
) |
273 (0 << CP0C1_IS
) | (3 << CP0C1_IL
) | (1 << CP0C1_IA
) |
274 (0 << CP0C1_DS
) | (3 << CP0C1_DL
) | (1 << CP0C1_DA
) |
276 .CP0_Config2
= MIPS_CONFIG2
,
277 .CP0_Config3
= MIPS_CONFIG3
| (1 << CP0C3_VInt
) | (1 << CP0C3_MT
) |
279 .CP0_LLAddr_rw_bitmask
= 0,
280 .CP0_LLAddr_shift
= 0,
283 .CP0_Status_rw_bitmask
= 0x3778FF1F,
284 .CP0_TCStatus_rw_bitmask
= (0 << CP0TCSt_TCU3
) | (0 << CP0TCSt_TCU2
) |
285 (1 << CP0TCSt_TCU1
) | (1 << CP0TCSt_TCU0
) |
286 (0 << CP0TCSt_TMX
) | (1 << CP0TCSt_DT
) |
287 (1 << CP0TCSt_DA
) | (1 << CP0TCSt_A
) |
288 (0x3 << CP0TCSt_TKSU
) | (1 << CP0TCSt_IXMT
) |
289 (0xff << CP0TCSt_TASID
),
290 .CP1_fcr0
= (1 << FCR0_F64
) | (1 << FCR0_L
) | (1 << FCR0_W
) |
291 (1 << FCR0_D
) | (1 << FCR0_S
) | (0x95 << FCR0_PRID
),
292 .CP0_SRSCtl
= (0xf << CP0SRSCtl_HSS
),
293 .CP0_SRSConf0_rw_bitmask
= 0x3fffffff,
294 .CP0_SRSConf0
= (1 << CP0SRSC0_M
) | (0x3fe << CP0SRSC0_SRS3
) |
295 (0x3fe << CP0SRSC0_SRS2
) | (0x3fe << CP0SRSC0_SRS1
),
296 .CP0_SRSConf1_rw_bitmask
= 0x3fffffff,
297 .CP0_SRSConf1
= (1 << CP0SRSC1_M
) | (0x3fe << CP0SRSC1_SRS6
) |
298 (0x3fe << CP0SRSC1_SRS5
) | (0x3fe << CP0SRSC1_SRS4
),
299 .CP0_SRSConf2_rw_bitmask
= 0x3fffffff,
300 .CP0_SRSConf2
= (1 << CP0SRSC2_M
) | (0x3fe << CP0SRSC2_SRS9
) |
301 (0x3fe << CP0SRSC2_SRS8
) | (0x3fe << CP0SRSC2_SRS7
),
302 .CP0_SRSConf3_rw_bitmask
= 0x3fffffff,
303 .CP0_SRSConf3
= (1 << CP0SRSC3_M
) | (0x3fe << CP0SRSC3_SRS12
) |
304 (0x3fe << CP0SRSC3_SRS11
) | (0x3fe << CP0SRSC3_SRS10
),
305 .CP0_SRSConf4_rw_bitmask
= 0x3fffffff,
306 .CP0_SRSConf4
= (0x3fe << CP0SRSC4_SRS15
) |
307 (0x3fe << CP0SRSC4_SRS14
) | (0x3fe << CP0SRSC4_SRS13
),
310 .insn_flags
= CPU_MIPS32R2
| ASE_MIPS16
| ASE_DSP
| ASE_MT
,
311 .mmu_type
= MMU_TYPE_R4000
,
315 .CP0_PRid
= 0x00019700,
316 .CP0_Config0
= MIPS_CONFIG0
| (0x1 << CP0C0_AR
) |
317 (MMU_TYPE_R4000
<< CP0C0_MT
),
318 .CP0_Config1
= MIPS_CONFIG1
| (1 << CP0C1_FP
) | (15 << CP0C1_MMU
) |
319 (0 << CP0C1_IS
) | (3 << CP0C1_IL
) | (1 << CP0C1_IA
) |
320 (0 << CP0C1_DS
) | (3 << CP0C1_DL
) | (1 << CP0C1_DA
) |
322 .CP0_Config2
= MIPS_CONFIG2
,
323 .CP0_Config3
= MIPS_CONFIG3
| (0 << CP0C3_VInt
) | (1 << CP0C3_DSPP
),
324 .CP0_LLAddr_rw_bitmask
= 0,
325 .CP0_LLAddr_shift
= 4,
328 .CP0_Status_rw_bitmask
= 0x3778FF1F,
329 .CP1_fcr0
= (1 << FCR0_F64
) | (1 << FCR0_L
) | (1 << FCR0_W
) |
330 (1 << FCR0_D
) | (1 << FCR0_S
) | (0x93 << FCR0_PRID
),
333 .insn_flags
= CPU_MIPS32R2
| ASE_MIPS16
| ASE_DSP
| ASE_DSPR2
,
334 .mmu_type
= MMU_TYPE_R4000
,
336 #if defined(TARGET_MIPS64)
339 .CP0_PRid
= 0x00000400,
340 /* No L2 cache, icache size 8k, dcache size 8k, uncached coherency. */
341 .CP0_Config0
= (1 << 17) | (0x1 << 9) | (0x1 << 6) | (0x2 << CP0C0_K0
),
342 /* Note: Config1 is only used internally, the R4000 has only Config0. */
343 .CP0_Config1
= (1 << CP0C1_FP
) | (47 << CP0C1_MMU
),
344 .CP0_LLAddr_rw_bitmask
= 0xFFFFFFFF,
345 .CP0_LLAddr_shift
= 4,
348 .CP0_Status_rw_bitmask
= 0x3678FFFF,
349 /* The R4000 has a full 64bit FPU but doesn't use the fcr0 bits. */
350 .CP1_fcr0
= (0x5 << FCR0_PRID
) | (0x0 << FCR0_REV
),
353 .insn_flags
= CPU_MIPS3
,
354 .mmu_type
= MMU_TYPE_R4000
,
358 .CP0_PRid
= 0x00005400,
359 /* No L2 cache, icache size 8k, dcache size 8k, uncached coherency. */
360 .CP0_Config0
= (1 << 17) | (0x1 << 9) | (0x1 << 6) | (0x2 << CP0C0_K0
),
361 .CP0_Config1
= (1 << CP0C1_FP
) | (47 << CP0C1_MMU
),
362 .CP0_LLAddr_rw_bitmask
= 0xFFFFFFFFL
,
363 .CP0_LLAddr_shift
= 4,
366 .CP0_Status_rw_bitmask
= 0x3678FFFF,
367 /* The VR5432 has a full 64bit FPU but doesn't use the fcr0 bits. */
368 .CP1_fcr0
= (0x54 << FCR0_PRID
) | (0x0 << FCR0_REV
),
371 .insn_flags
= CPU_VR54XX
,
372 .mmu_type
= MMU_TYPE_R4000
,
376 .CP0_PRid
= 0x00018100,
377 .CP0_Config0
= MIPS_CONFIG0
| (0x2 << CP0C0_AT
) |
378 (MMU_TYPE_R4000
<< CP0C0_MT
),
379 .CP0_Config1
= MIPS_CONFIG1
| (31 << CP0C1_MMU
) |
380 (1 << CP0C1_IS
) | (4 << CP0C1_IL
) | (1 << CP0C1_IA
) |
381 (1 << CP0C1_DS
) | (4 << CP0C1_DL
) | (1 << CP0C1_DA
) |
382 (1 << CP0C1_PC
) | (1 << CP0C1_WR
) | (1 << CP0C1_EP
),
383 .CP0_Config2
= MIPS_CONFIG2
,
384 .CP0_Config3
= MIPS_CONFIG3
,
385 .CP0_LLAddr_rw_bitmask
= 0,
386 .CP0_LLAddr_shift
= 4,
389 .CP0_Status_rw_bitmask
= 0x32F8FFFF,
392 .insn_flags
= CPU_MIPS64
,
393 .mmu_type
= MMU_TYPE_R4000
,
397 .CP0_PRid
= 0x00018100,
398 .CP0_Config0
= MIPS_CONFIG0
| (0x2 << CP0C0_AT
) |
399 (MMU_TYPE_R4000
<< CP0C0_MT
),
400 .CP0_Config1
= MIPS_CONFIG1
| (1 << CP0C1_FP
) | (31 << CP0C1_MMU
) |
401 (1 << CP0C1_IS
) | (4 << CP0C1_IL
) | (1 << CP0C1_IA
) |
402 (1 << CP0C1_DS
) | (4 << CP0C1_DL
) | (1 << CP0C1_DA
) |
403 (1 << CP0C1_PC
) | (1 << CP0C1_WR
) | (1 << CP0C1_EP
),
404 .CP0_Config2
= MIPS_CONFIG2
,
405 .CP0_Config3
= MIPS_CONFIG3
,
406 .CP0_LLAddr_rw_bitmask
= 0,
407 .CP0_LLAddr_shift
= 4,
410 .CP0_Status_rw_bitmask
= 0x36F8FFFF,
411 /* The 5Kf has F64 / L / W but doesn't use the fcr0 bits. */
412 .CP1_fcr0
= (1 << FCR0_D
) | (1 << FCR0_S
) |
413 (0x81 << FCR0_PRID
) | (0x0 << FCR0_REV
),
416 .insn_flags
= CPU_MIPS64
,
417 .mmu_type
= MMU_TYPE_R4000
,
421 /* We emulate a later version of the 20Kc, earlier ones had a broken
423 .CP0_PRid
= 0x000182a0,
424 .CP0_Config0
= MIPS_CONFIG0
| (0x2 << CP0C0_AT
) |
425 (MMU_TYPE_R4000
<< CP0C0_MT
) | (1 << CP0C0_VI
),
426 .CP0_Config1
= MIPS_CONFIG1
| (1 << CP0C1_FP
) | (47 << CP0C1_MMU
) |
427 (2 << CP0C1_IS
) | (4 << CP0C1_IL
) | (3 << CP0C1_IA
) |
428 (2 << CP0C1_DS
) | (4 << CP0C1_DL
) | (3 << CP0C1_DA
) |
429 (1 << CP0C1_PC
) | (1 << CP0C1_WR
) | (1 << CP0C1_EP
),
430 .CP0_Config2
= MIPS_CONFIG2
,
431 .CP0_Config3
= MIPS_CONFIG3
,
432 .CP0_LLAddr_rw_bitmask
= 0,
433 .CP0_LLAddr_shift
= 0,
436 .CP0_Status_rw_bitmask
= 0x36FBFFFF,
437 /* The 20Kc has F64 / L / W but doesn't use the fcr0 bits. */
438 .CP1_fcr0
= (1 << FCR0_3D
) | (1 << FCR0_PS
) |
439 (1 << FCR0_D
) | (1 << FCR0_S
) |
440 (0x82 << FCR0_PRID
) | (0x0 << FCR0_REV
),
443 .insn_flags
= CPU_MIPS64
| ASE_MIPS3D
,
444 .mmu_type
= MMU_TYPE_R4000
,
447 /* A generic CPU providing MIPS64 Release 2 features.
448 FIXME: Eventually this should be replaced by a real CPU model. */
449 .name
= "MIPS64R2-generic",
450 .CP0_PRid
= 0x00010000,
451 .CP0_Config0
= MIPS_CONFIG0
| (0x1 << CP0C0_AR
) | (0x2 << CP0C0_AT
) |
452 (MMU_TYPE_R4000
<< CP0C0_MT
),
453 .CP0_Config1
= MIPS_CONFIG1
| (1 << CP0C1_FP
) | (63 << CP0C1_MMU
) |
454 (2 << CP0C1_IS
) | (4 << CP0C1_IL
) | (3 << CP0C1_IA
) |
455 (2 << CP0C1_DS
) | (4 << CP0C1_DL
) | (3 << CP0C1_DA
) |
456 (1 << CP0C1_PC
) | (1 << CP0C1_WR
) | (1 << CP0C1_EP
),
457 .CP0_Config2
= MIPS_CONFIG2
,
458 .CP0_Config3
= MIPS_CONFIG3
| (1 << CP0C3_LPA
),
459 .CP0_LLAddr_rw_bitmask
= 0,
460 .CP0_LLAddr_shift
= 0,
463 .CP0_Status_rw_bitmask
= 0x36FBFFFF,
464 .CP1_fcr0
= (1 << FCR0_F64
) | (1 << FCR0_3D
) | (1 << FCR0_PS
) |
465 (1 << FCR0_L
) | (1 << FCR0_W
) | (1 << FCR0_D
) |
466 (1 << FCR0_S
) | (0x00 << FCR0_PRID
) | (0x0 << FCR0_REV
),
468 /* The architectural limit is 59, but we have hardcoded 36 bit
470 .PABITS = 59, */ /* the architectural limit */
472 .insn_flags
= CPU_MIPS64R2
| ASE_MIPS3D
,
473 .mmu_type
= MMU_TYPE_R4000
,
476 .name
= "Loongson-2E",
478 /*64KB I-cache and d-cache. 4 way with 32 bit cache line size*/
479 .CP0_Config0
= (0x1<<17) | (0x1<<16) | (0x1<<11) | (0x1<<8) | (0x1<<5) |
481 /* Note: Config1 is only used internally, Loongson-2E has only Config0. */
482 .CP0_Config1
= (1 << CP0C1_FP
) | (47 << CP0C1_MMU
),
485 .CP0_Status_rw_bitmask
= 0x35D0FFFF,
486 .CP1_fcr0
= (0x5 << FCR0_PRID
) | (0x1 << FCR0_REV
),
489 .insn_flags
= CPU_LOONGSON2E
,
490 .mmu_type
= MMU_TYPE_R4000
,
493 .name
= "Loongson-2F",
495 /*64KB I-cache and d-cache. 4 way with 32 bit cache line size*/
496 .CP0_Config0
= (0x1<<17) | (0x1<<16) | (0x1<<11) | (0x1<<8) | (0x1<<5) |
498 /* Note: Config1 is only used internally, Loongson-2F has only Config0. */
499 .CP0_Config1
= (1 << CP0C1_FP
) | (47 << CP0C1_MMU
),
502 .CP0_Status_rw_bitmask
= 0xF5D0FF1F, /*bit5:7 not writable*/
503 .CP1_fcr0
= (0x5 << FCR0_PRID
) | (0x1 << FCR0_REV
),
506 .insn_flags
= CPU_LOONGSON2F
,
507 .mmu_type
= MMU_TYPE_R4000
,
510 /* A generic CPU providing MIPS64 ASE DSP 2 features.
511 FIXME: Eventually this should be replaced by a real CPU model. */
512 .name
= "mips64dspr2",
513 .CP0_PRid
= 0x00010000,
514 .CP0_Config0
= MIPS_CONFIG0
| (0x1 << CP0C0_AR
) | (0x2 << CP0C0_AT
) |
515 (MMU_TYPE_R4000
<< CP0C0_MT
),
516 .CP0_Config1
= MIPS_CONFIG1
| (1 << CP0C1_FP
) | (63 << CP0C1_MMU
) |
517 (2 << CP0C1_IS
) | (4 << CP0C1_IL
) | (3 << CP0C1_IA
) |
518 (2 << CP0C1_DS
) | (4 << CP0C1_DL
) | (3 << CP0C1_DA
) |
519 (1 << CP0C1_PC
) | (1 << CP0C1_WR
) | (1 << CP0C1_EP
),
520 .CP0_Config2
= MIPS_CONFIG2
,
521 .CP0_Config3
= MIPS_CONFIG3
| (1 << CP0C3_LPA
),
522 .CP0_LLAddr_rw_bitmask
= 0,
523 .CP0_LLAddr_shift
= 0,
526 .CP0_Status_rw_bitmask
= 0x37FBFFFF,
527 .CP1_fcr0
= (1 << FCR0_F64
) | (1 << FCR0_3D
) | (1 << FCR0_PS
) |
528 (1 << FCR0_L
) | (1 << FCR0_W
) | (1 << FCR0_D
) |
529 (1 << FCR0_S
) | (0x00 << FCR0_PRID
) | (0x0 << FCR0_REV
),
531 /* The architectural limit is 59, but we have hardcoded 36 bit
533 .PABITS = 59, */ /* the architectural limit */
535 .insn_flags
= CPU_MIPS64R2
| ASE_DSP
| ASE_DSPR2
,
536 .mmu_type
= MMU_TYPE_R4000
,
542 static const mips_def_t
*cpu_mips_find_by_name (const char *name
)
546 for (i
= 0; i
< ARRAY_SIZE(mips_defs
); i
++) {
547 if (strcasecmp(name
, mips_defs
[i
].name
) == 0) {
548 return &mips_defs
[i
];
554 void mips_cpu_list (FILE *f
, fprintf_function cpu_fprintf
)
558 for (i
= 0; i
< ARRAY_SIZE(mips_defs
); i
++) {
559 (*cpu_fprintf
)(f
, "MIPS '%s'\n",
564 #ifndef CONFIG_USER_ONLY
565 static void no_mmu_init (CPUMIPSState
*env
, const mips_def_t
*def
)
567 env
->tlb
->nb_tlb
= 1;
568 env
->tlb
->map_address
= &no_mmu_map_address
;
571 static void fixed_mmu_init (CPUMIPSState
*env
, const mips_def_t
*def
)
573 env
->tlb
->nb_tlb
= 1;
574 env
->tlb
->map_address
= &fixed_mmu_map_address
;
577 static void r4k_mmu_init (CPUMIPSState
*env
, const mips_def_t
*def
)
579 env
->tlb
->nb_tlb
= 1 + ((def
->CP0_Config1
>> CP0C1_MMU
) & 63);
580 env
->tlb
->map_address
= &r4k_map_address
;
581 env
->tlb
->helper_tlbwi
= r4k_helper_tlbwi
;
582 env
->tlb
->helper_tlbwr
= r4k_helper_tlbwr
;
583 env
->tlb
->helper_tlbp
= r4k_helper_tlbp
;
584 env
->tlb
->helper_tlbr
= r4k_helper_tlbr
;
587 static void mmu_init (CPUMIPSState
*env
, const mips_def_t
*def
)
589 env
->tlb
= g_malloc0(sizeof(CPUMIPSTLBContext
));
591 switch (def
->mmu_type
) {
593 no_mmu_init(env
, def
);
596 r4k_mmu_init(env
, def
);
599 fixed_mmu_init(env
, def
);
605 cpu_abort(env
, "MMU type not supported\n");
608 #endif /* CONFIG_USER_ONLY */
610 static void fpu_init (CPUMIPSState
*env
, const mips_def_t
*def
)
614 for (i
= 0; i
< MIPS_FPU_MAX
; i
++)
615 env
->fpus
[i
].fcr0
= def
->CP1_fcr0
;
617 memcpy(&env
->active_fpu
, &env
->fpus
[0], sizeof(env
->active_fpu
));
620 static void mvp_init (CPUMIPSState
*env
, const mips_def_t
*def
)
622 env
->mvp
= g_malloc0(sizeof(CPUMIPSMVPContext
));
624 /* MVPConf1 implemented, TLB sharable, no gating storage support,
625 programmable cache partitioning implemented, number of allocatable
626 and sharable TLB entries, MVP has allocatable TCs, 2 VPEs
627 implemented, 5 TCs implemented. */
628 env
->mvp
->CP0_MVPConf0
= (1 << CP0MVPC0_M
) | (1 << CP0MVPC0_TLBS
) |
629 (0 << CP0MVPC0_GS
) | (1 << CP0MVPC0_PCP
) |
630 // TODO: actually do 2 VPEs.
631 // (1 << CP0MVPC0_TCA) | (0x1 << CP0MVPC0_PVPE) |
632 // (0x04 << CP0MVPC0_PTC);
633 (1 << CP0MVPC0_TCA
) | (0x0 << CP0MVPC0_PVPE
) |
634 (0x00 << CP0MVPC0_PTC
);
635 #if !defined(CONFIG_USER_ONLY)
636 /* Usermode has no TLB support */
637 env
->mvp
->CP0_MVPConf0
|= (env
->tlb
->nb_tlb
<< CP0MVPC0_PTLBE
);
640 /* Allocatable CP1 have media extensions, allocatable CP1 have FP support,
641 no UDI implemented, no CP2 implemented, 1 CP1 implemented. */
642 env
->mvp
->CP0_MVPConf1
= (1 << CP0MVPC1_CIM
) | (1 << CP0MVPC1_CIF
) |
643 (0x0 << CP0MVPC1_PCX
) | (0x0 << CP0MVPC1_PCP2
) |
644 (0x1 << CP0MVPC1_PCP1
);