xref: /openbmc/qemu/target/mips/cpu-defs.c.inc (revision 45e576c7)
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.1 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, see <http://www.gnu.org/licenses/>.
19 */
20
21/* CPU / CPU family specific config register values. */
22
23/* Have config1, uncached coherency */
24#define MIPS_CONFIG0                                              \
25  ((1U << CP0C0_M) | (0x2 << CP0C0_K0))
26
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                                              \
31((1U << CP0C1_M) |                                                \
32 (0 << CP0C1_C2) | (0 << CP0C1_MD) | (0 << CP0C1_PC) |            \
33 (1 << CP0C1_WR) | (0 << CP0C1_CA) | (1 << CP0C1_EP) |            \
34 (0 << CP0C1_FP))
35
36/* Have config3, no tertiary/secondary caches implemented */
37#define MIPS_CONFIG2                                              \
38((1U << CP0C2_M))
39
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))
47
48#define MIPS_CONFIG4                                              \
49((0 << CP0C4_M))
50
51#define MIPS_CONFIG5                                              \
52((0 << CP0C5_M))
53
54/*****************************************************************************/
55/* MIPS CPU definitions */
56const mips_def_t mips_defs[] =
57{
58    {
59        .name = "4Kc",
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) |
65                       (0 << CP0C1_CA),
66        .CP0_Config2 = MIPS_CONFIG2,
67        .CP0_Config3 = MIPS_CONFIG3,
68        .CP0_LLAddr_rw_bitmask = 0,
69        .CP0_LLAddr_shift = 4,
70        .SYNCI_Step = 32,
71        .CCRes = 2,
72        .CP0_Status_rw_bitmask = 0x1278FF17,
73        .SEGBITS = 32,
74        .PABITS = 32,
75        .insn_flags = CPU_MIPS32R1,
76        .mmu_type = MMU_TYPE_R4000,
77    },
78    {
79        .name = "4Km",
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) |
87                       (1 << CP0C1_CA),
88        .CP0_Config2 = MIPS_CONFIG2,
89        .CP0_Config3 = MIPS_CONFIG3,
90        .CP0_LLAddr_rw_bitmask = 0,
91        .CP0_LLAddr_shift = 4,
92        .SYNCI_Step = 32,
93        .CCRes = 2,
94        .CP0_Status_rw_bitmask = 0x1258FF17,
95        .SEGBITS = 32,
96        .PABITS = 32,
97        .insn_flags = CPU_MIPS32R1 | ASE_MIPS16,
98        .mmu_type = MMU_TYPE_FMT,
99    },
100    {
101        .name = "4KEcR1",
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) |
107                       (0 << CP0C1_CA),
108        .CP0_Config2 = MIPS_CONFIG2,
109        .CP0_Config3 = MIPS_CONFIG3,
110        .CP0_LLAddr_rw_bitmask = 0,
111        .CP0_LLAddr_shift = 4,
112        .SYNCI_Step = 32,
113        .CCRes = 2,
114        .CP0_Status_rw_bitmask = 0x1278FF17,
115        .SEGBITS = 32,
116        .PABITS = 32,
117        .insn_flags = CPU_MIPS32R1,
118        .mmu_type = MMU_TYPE_R4000,
119    },
120    {
121        .name = "4KEmR1",
122        .CP0_PRid = 0x00018500,
123        .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_FMT << CP0C0_MT),
124        .CP0_Config1 = MIPS_CONFIG1 |
125                       (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
126                       (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
127                       (1 << CP0C1_CA),
128        .CP0_Config2 = MIPS_CONFIG2,
129        .CP0_Config3 = MIPS_CONFIG3,
130        .CP0_LLAddr_rw_bitmask = 0,
131        .CP0_LLAddr_shift = 4,
132        .SYNCI_Step = 32,
133        .CCRes = 2,
134        .CP0_Status_rw_bitmask = 0x1258FF17,
135        .SEGBITS = 32,
136        .PABITS = 32,
137        .insn_flags = CPU_MIPS32R1 | ASE_MIPS16,
138        .mmu_type = MMU_TYPE_FMT,
139    },
140    {
141        .name = "4KEc",
142        .CP0_PRid = 0x00019000,
143        .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
144                    (MMU_TYPE_R4000 << CP0C0_MT),
145        .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
146                       (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
147                       (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
148                       (0 << CP0C1_CA),
149        .CP0_Config2 = MIPS_CONFIG2,
150        .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
151        .CP0_LLAddr_rw_bitmask = 0,
152        .CP0_LLAddr_shift = 4,
153        .SYNCI_Step = 32,
154        .CCRes = 2,
155        .CP0_Status_rw_bitmask = 0x1278FF17,
156        .SEGBITS = 32,
157        .PABITS = 32,
158        .insn_flags = CPU_MIPS32R2,
159        .mmu_type = MMU_TYPE_R4000,
160    },
161    {
162        .name = "4KEm",
163        .CP0_PRid = 0x00019100,
164        .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
165                       (MMU_TYPE_FMT << CP0C0_MT),
166        .CP0_Config1 = MIPS_CONFIG1 |
167                       (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
168                       (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
169                       (1 << CP0C1_CA),
170        .CP0_Config2 = MIPS_CONFIG2,
171        .CP0_Config3 = MIPS_CONFIG3,
172        .CP0_LLAddr_rw_bitmask = 0,
173        .CP0_LLAddr_shift = 4,
174        .SYNCI_Step = 32,
175        .CCRes = 2,
176        .CP0_Status_rw_bitmask = 0x1258FF17,
177        .SEGBITS = 32,
178        .PABITS = 32,
179        .insn_flags = CPU_MIPS32R2 | ASE_MIPS16,
180        .mmu_type = MMU_TYPE_FMT,
181    },
182    {
183        .name = "24Kc",
184        .CP0_PRid = 0x00019300,
185        .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
186                       (MMU_TYPE_R4000 << CP0C0_MT),
187        .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
188                       (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
189                       (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
190                       (1 << CP0C1_CA),
191        .CP0_Config2 = MIPS_CONFIG2,
192        .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
193        .CP0_LLAddr_rw_bitmask = 0,
194        .CP0_LLAddr_shift = 4,
195        .SYNCI_Step = 32,
196        .CCRes = 2,
197        /* No DSP implemented. */
198        .CP0_Status_rw_bitmask = 0x1278FF1F,
199        .SEGBITS = 32,
200        .PABITS = 32,
201        .insn_flags = CPU_MIPS32R2 | ASE_MIPS16,
202        .mmu_type = MMU_TYPE_R4000,
203    },
204    {
205        .name = "24KEc",
206        .CP0_PRid = 0x00019600,
207        .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
208                       (MMU_TYPE_R4000 << CP0C0_MT),
209        .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
210                       (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
211                       (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
212                       (1 << CP0C1_CA),
213        .CP0_Config2 = MIPS_CONFIG2,
214        .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_DSPP) | (0 << CP0C3_VInt),
215        .CP0_LLAddr_rw_bitmask = 0,
216        .CP0_LLAddr_shift = 4,
217        .SYNCI_Step = 32,
218        .CCRes = 2,
219        /* we have a DSP, but no FPU */
220        .CP0_Status_rw_bitmask = 0x1378FF1F,
221        .SEGBITS = 32,
222        .PABITS = 32,
223        .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP,
224        .mmu_type = MMU_TYPE_R4000,
225    },
226    {
227        .name = "24Kf",
228        .CP0_PRid = 0x00019300,
229        .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
230                    (MMU_TYPE_R4000 << CP0C0_MT),
231        .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
232                       (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
233                       (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
234                       (1 << CP0C1_CA),
235        .CP0_Config2 = MIPS_CONFIG2,
236        .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
237        .CP0_LLAddr_rw_bitmask = 0,
238        .CP0_LLAddr_shift = 4,
239        .SYNCI_Step = 32,
240        .CCRes = 2,
241        /* No DSP implemented. */
242        .CP0_Status_rw_bitmask = 0x3678FF1F,
243        .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
244                    (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID),
245        .CP1_fcr31 = 0,
246        .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
247        .SEGBITS = 32,
248        .PABITS = 32,
249        .insn_flags = CPU_MIPS32R2 | ASE_MIPS16,
250        .mmu_type = MMU_TYPE_R4000,
251    },
252    {
253        .name = "34Kf",
254        .CP0_PRid = 0x00019500,
255        .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
256                       (MMU_TYPE_R4000 << CP0C0_MT),
257        .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) |
258                       (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
259                       (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
260                       (1 << CP0C1_CA),
261        .CP0_Config2 = MIPS_CONFIG2,
262        .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_VInt) | (1 << CP0C3_MT) |
263                       (1 << CP0C3_DSPP),
264        .CP0_LLAddr_rw_bitmask = 0,
265        .CP0_LLAddr_shift = 0,
266        .SYNCI_Step = 32,
267        .CCRes = 2,
268        .CP0_Status_rw_bitmask = 0x3778FF1F,
269        .CP0_TCStatus_rw_bitmask = (0 << CP0TCSt_TCU3) | (0 << CP0TCSt_TCU2) |
270                    (1 << CP0TCSt_TCU1) | (1 << CP0TCSt_TCU0) |
271                    (0 << CP0TCSt_TMX) | (1 << CP0TCSt_DT) |
272                    (1 << CP0TCSt_DA) | (1 << CP0TCSt_A) |
273                    (0x3 << CP0TCSt_TKSU) | (1 << CP0TCSt_IXMT) |
274                    (0xff << CP0TCSt_TASID),
275        .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
276                    (1 << FCR0_D) | (1 << FCR0_S) | (0x95 << FCR0_PRID),
277        .CP1_fcr31 = 0,
278        .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
279        .CP0_SRSCtl = (0xf << CP0SRSCtl_HSS),
280        .CP0_SRSConf0_rw_bitmask = 0x3fffffff,
281        .CP0_SRSConf0 = (1U << CP0SRSC0_M) | (0x3fe << CP0SRSC0_SRS3) |
282                    (0x3fe << CP0SRSC0_SRS2) | (0x3fe << CP0SRSC0_SRS1),
283        .CP0_SRSConf1_rw_bitmask = 0x3fffffff,
284        .CP0_SRSConf1 = (1U << CP0SRSC1_M) | (0x3fe << CP0SRSC1_SRS6) |
285                    (0x3fe << CP0SRSC1_SRS5) | (0x3fe << CP0SRSC1_SRS4),
286        .CP0_SRSConf2_rw_bitmask = 0x3fffffff,
287        .CP0_SRSConf2 = (1U << CP0SRSC2_M) | (0x3fe << CP0SRSC2_SRS9) |
288                    (0x3fe << CP0SRSC2_SRS8) | (0x3fe << CP0SRSC2_SRS7),
289        .CP0_SRSConf3_rw_bitmask = 0x3fffffff,
290        .CP0_SRSConf3 = (1U << CP0SRSC3_M) | (0x3fe << CP0SRSC3_SRS12) |
291                    (0x3fe << CP0SRSC3_SRS11) | (0x3fe << CP0SRSC3_SRS10),
292        .CP0_SRSConf4_rw_bitmask = 0x3fffffff,
293        .CP0_SRSConf4 = (0x3fe << CP0SRSC4_SRS15) |
294                    (0x3fe << CP0SRSC4_SRS14) | (0x3fe << CP0SRSC4_SRS13),
295        .SEGBITS = 32,
296        .PABITS = 32,
297        .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_MT,
298        .mmu_type = MMU_TYPE_R4000,
299    },
300    {
301        .name = "74Kf",
302        .CP0_PRid = 0x00019700,
303        .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
304                    (MMU_TYPE_R4000 << CP0C0_MT),
305        .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
306                       (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
307                       (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
308                       (1 << CP0C1_CA),
309        .CP0_Config2 = MIPS_CONFIG2,
310        .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_DSP2P) | (1 << CP0C3_DSPP) |
311                       (1 << CP0C3_VInt),
312        .CP0_LLAddr_rw_bitmask = 0,
313        .CP0_LLAddr_shift = 4,
314        .SYNCI_Step = 32,
315        .CCRes = 2,
316        .CP0_Status_rw_bitmask = 0x3778FF1F,
317        .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
318                    (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID),
319        .CP1_fcr31 = 0,
320        .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
321        .SEGBITS = 32,
322        .PABITS = 32,
323        .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_DSP_R2,
324        .mmu_type = MMU_TYPE_R4000,
325    },
326    {
327        .name = "M14K",
328        .CP0_PRid = 0x00019b00,
329        /* Config1 implemented, fixed mapping MMU,
330           no virtual icache, uncached coherency. */
331        .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_KU) | (0x2 << CP0C0_K23) |
332                       (0x1 << CP0C0_AR) | (MMU_TYPE_FMT << CP0C0_MT),
333        .CP0_Config1 = MIPS_CONFIG1,
334        .CP0_Config2 = MIPS_CONFIG2,
335        .CP0_Config3 = MIPS_CONFIG3 | (0x2 << CP0C3_ISA) | (1 << CP0C3_VInt),
336        .CP0_LLAddr_rw_bitmask = 0,
337        .CP0_LLAddr_shift = 4,
338        .SYNCI_Step = 32,
339        .CCRes = 2,
340        .CP0_Status_rw_bitmask = 0x1258FF17,
341        .SEGBITS = 32,
342        .PABITS = 32,
343        .insn_flags = CPU_MIPS32R2 | ASE_MICROMIPS,
344        .mmu_type = MMU_TYPE_FMT,
345    },
346    {
347        .name = "M14Kc",
348        /* This is the TLB-based MMU core.  */
349        .CP0_PRid = 0x00019c00,
350        .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
351                       (MMU_TYPE_R4000 << CP0C0_MT),
352        .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
353                       (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
354                       (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA),
355        .CP0_Config2 = MIPS_CONFIG2,
356        .CP0_Config3 = MIPS_CONFIG3 | (0x2 << CP0C3_ISA) | (0 << CP0C3_VInt),
357        .CP0_LLAddr_rw_bitmask = 0,
358        .CP0_LLAddr_shift = 4,
359        .SYNCI_Step = 32,
360        .CCRes = 2,
361        .CP0_Status_rw_bitmask = 0x1278FF17,
362        .SEGBITS = 32,
363        .PABITS = 32,
364        .insn_flags = CPU_MIPS32R2 | ASE_MICROMIPS,
365        .mmu_type = MMU_TYPE_R4000,
366    },
367    {
368        /* FIXME:
369         * Config3: VZ, CTXTC, CDMM, TL
370         * Config4: MMUExtDef
371         * Config5: MRP
372         * FIR(FCR0): Has2008
373         * */
374        .name = "P5600",
375        .CP0_PRid = 0x0001A800,
376        .CP0_Config0 = MIPS_CONFIG0 | (1 << CP0C0_MM) | (1 << CP0C0_AR) |
377                    (MMU_TYPE_R4000 << CP0C0_MT),
378        .CP0_Config1 = MIPS_CONFIG1 | (0x3F << CP0C1_MMU) |
379                       (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
380                       (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
381                       (1 << CP0C1_PC) | (1 << CP0C1_FP),
382        .CP0_Config2 = MIPS_CONFIG2,
383        .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) |
384                       (1 << CP0C3_CMGCR) | (1 << CP0C3_MSAP) |
385                       (1 << CP0C3_BP) | (1 << CP0C3_BI) | (1 << CP0C3_SC) |
386                       (1 << CP0C3_PW) | (1 << CP0C3_ULRI) | (1 << CP0C3_RXI) |
387                       (1 << CP0C3_LPA) | (1 << CP0C3_VInt),
388        .CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | (2 << CP0C4_IE) |
389                       (0x1c << CP0C4_KScrExist),
390        .CP0_Config4_rw_bitmask = 0,
391        .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_EVA) | (1 << CP0C5_MVH) |
392                       (1 << CP0C5_LLB) | (1 << CP0C5_MRP),
393        .CP0_Config5_rw_bitmask = (1 << CP0C5_K) | (1 << CP0C5_CV) |
394                                  (1 << CP0C5_MSAEn) | (1 << CP0C5_UFE) |
395                                  (1 << CP0C5_FRE) | (1 << CP0C5_UFR),
396        .CP0_LLAddr_rw_bitmask = 0,
397        .CP0_LLAddr_shift = 0,
398        .SYNCI_Step = 32,
399        .CCRes = 2,
400        .CP0_Status_rw_bitmask = 0x3C68FF1F,
401        .CP0_PageGrain_rw_bitmask = (1U << CP0PG_RIE) | (1 << CP0PG_XIE) |
402                    (1 << CP0PG_ELPA) | (1 << CP0PG_IEC),
403        .CP0_EBaseWG_rw_bitmask = (1 << CP0EBase_WG),
404        .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_UFRP) | (1 << FCR0_HAS2008) |
405                    (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
406                    (1 << FCR0_D) | (1 << FCR0_S) | (0x03 << FCR0_PRID),
407        .CP1_fcr31 = (1 << FCR31_ABS2008) | (1 << FCR31_NAN2008),
408        .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
409        .SEGBITS = 32,
410        .PABITS = 40,
411        .insn_flags = CPU_MIPS32R5,
412        .mmu_type = MMU_TYPE_R4000,
413    },
414    {
415        /* A generic CPU supporting MIPS32 Release 6 ISA.
416           FIXME: Support IEEE 754-2008 FP.
417                  Eventually this should be replaced by a real CPU model. */
418        .name = "mips32r6-generic",
419        .CP0_PRid = 0x00010000,
420        .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AR) |
421                       (MMU_TYPE_R4000 << CP0C0_MT),
422        .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (31 << CP0C1_MMU) |
423                       (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
424                       (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
425                       (0 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
426        .CP0_Config2 = MIPS_CONFIG2,
427        .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_BP) | (1 << CP0C3_BI) |
428                       (2 << CP0C3_ISA) | (1 << CP0C3_ULRI) |
429                       (1 << CP0C3_RXI) | (1U << CP0C3_M),
430        .CP0_Config4 = MIPS_CONFIG4 | (0xfc << CP0C4_KScrExist) |
431                       (3 << CP0C4_IE) | (1U << CP0C4_M),
432        .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_XNP) | (1 << CP0C5_LLB),
433        .CP0_Config5_rw_bitmask = (1 << CP0C5_SBRI) | (1 << CP0C5_FRE) |
434                                  (1 << CP0C5_UFE),
435        .CP0_LLAddr_rw_bitmask = 0,
436        .CP0_LLAddr_shift = 0,
437        .SYNCI_Step = 32,
438        .CCRes = 2,
439        .CP0_Status_rw_bitmask = 0x3058FF1F,
440        .CP0_PageGrain = (1 << CP0PG_IEC) | (1 << CP0PG_XIE) |
441                         (1U << CP0PG_RIE),
442        .CP0_PageGrain_rw_bitmask = 0,
443        .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_HAS2008) | (1 << FCR0_F64) |
444                    (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
445                    (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV),
446        .CP1_fcr31 = (1 << FCR31_ABS2008) | (1 << FCR31_NAN2008),
447        .CP1_fcr31_rw_bitmask = 0x0103FFFF,
448        .SEGBITS = 32,
449        .PABITS = 32,
450        .insn_flags = CPU_MIPS32R6 | ASE_MICROMIPS,
451        .mmu_type = MMU_TYPE_R4000,
452    },
453    {
454        .name = "I7200",
455        .CP0_PRid = 0x00010000,
456        .CP0_Config0 = MIPS_CONFIG0 | (1 << CP0C0_MM) | (0x2 << CP0C0_AR) |
457                        (MMU_TYPE_R4000 << CP0C0_MT),
458        .CP0_Config1 = (1U << CP0C1_M) | (15 << CP0C1_MMU) | (2 << CP0C1_IS) |
459                       (4 << CP0C1_IL) | (3 << CP0C1_IA) | (2 << CP0C1_DS) |
460                       (4 << CP0C1_DL) | (3 << CP0C1_DA) | (1 << CP0C1_PC) |
461                       (1 << CP0C1_EP),
462        .CP0_Config2 = MIPS_CONFIG2,
463        .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) | (1 << CP0C3_CMGCR) |
464                       (1 << CP0C3_BI) | (1 << CP0C3_SC) | (3 << CP0C3_MMAR) |
465                       (1 << CP0C3_ISA_ON_EXC) | (1 << CP0C3_ISA) |
466                       (1 << CP0C3_ULRI) | (1 << CP0C3_RXI) |
467                       (1 << CP0C3_DSP2P) | (1 << CP0C3_DSPP) |
468                       (1 << CP0C3_CTXTC) | (1 << CP0C3_VInt) |
469                       (1 << CP0C3_CDMM) | (1 << CP0C3_MT) | (1 << CP0C3_TL),
470        .CP0_Config4 = MIPS_CONFIG4 | (0xfc << CP0C4_KScrExist) |
471                       (2 << CP0C4_IE) | (1U << CP0C4_M),
472        .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_MVH) | (1 << CP0C5_LLB),
473        .CP0_Config5_rw_bitmask = (1 << CP0C5_SBRI) | (1 << CP0C5_FRE) |
474                                  (1 << CP0C5_UFE),
475        .CP0_LLAddr_rw_bitmask = 0,
476        .CP0_LLAddr_shift = 0,
477        .SYNCI_Step = 32,
478        .CCRes = 2,
479        .CP0_Status_rw_bitmask = 0x3158FF1F,
480        .CP0_PageGrain = (1 << CP0PG_IEC) | (1 << CP0PG_XIE) |
481                         (1U << CP0PG_RIE),
482        .CP0_PageGrain_rw_bitmask = 0,
483        .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_HAS2008) | (1 << FCR0_F64) |
484                    (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
485                    (1 << FCR0_S) | (0x02 << FCR0_PRID) | (0x0 << FCR0_REV),
486        .CP1_fcr31 = (1 << FCR31_ABS2008) | (1 << FCR31_NAN2008),
487        .SEGBITS = 32,
488        .PABITS = 32,
489        .insn_flags = CPU_MIPS32R6 | ISA_NANOMIPS32 |
490                      ASE_DSP | ASE_DSP_R2 | ASE_DSP_R3 | ASE_MT,
491        .mmu_type = MMU_TYPE_R4000,
492    },
493#if defined(TARGET_MIPS64)
494    {
495        .name = "R4000",
496        .CP0_PRid = 0x00000400,
497        /* No L2 cache, icache size 8k, dcache size 8k, uncached coherency. */
498        .CP0_Config0 = (2 << CP0C0_Impl) | (1 << CP0C0_IC) | (1 << CP0C0_DC) |
499                       (2 << CP0C0_K0),
500        /* Note: Config1 is only used internally, the R4000 has only Config0. */
501        .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
502        .CP0_LLAddr_rw_bitmask = 0xFFFFFFFF,
503        .CP0_LLAddr_shift = 4,
504        .SYNCI_Step = 16,
505        .CCRes = 2,
506        .CP0_Status_rw_bitmask = 0x3678FFFF,
507        /* The R4000 has a full 64bit FPU but doesn't use the fcr0 bits. */
508        .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x0 << FCR0_REV),
509        .CP1_fcr31 = 0,
510        .CP1_fcr31_rw_bitmask = 0x0183FFFF,
511        .SEGBITS = 40,
512        .PABITS = 36,
513        .insn_flags = CPU_MIPS3,
514        .mmu_type = MMU_TYPE_R4000,
515    },
516    {
517        .name = "VR5432",
518        .CP0_PRid = 0x00005400,
519        /* No L2 cache, icache size 8k, dcache size 8k, uncached coherency. */
520        .CP0_Config0 = (2 << CP0C0_Impl) | (1 << CP0C0_IC) | (1 << CP0C0_DC) |
521                       (2 << CP0C0_K0),
522        .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
523        .CP0_LLAddr_rw_bitmask = 0xFFFFFFFFL,
524        .CP0_LLAddr_shift = 4,
525        .SYNCI_Step = 16,
526        .CCRes = 2,
527        .CP0_Status_rw_bitmask = 0x3678FFFF,
528        /* The VR5432 has a full 64bit FPU but doesn't use the fcr0 bits. */
529        .CP1_fcr0 = (0x54 << FCR0_PRID) | (0x0 << FCR0_REV),
530        .CP1_fcr31 = 0,
531        .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
532        .SEGBITS = 40,
533        .PABITS = 32,
534        .insn_flags = CPU_MIPS4 | INSN_VR54XX,
535        .mmu_type = MMU_TYPE_R4000,
536    },
537    {
538        .name = "5Kc",
539        .CP0_PRid = 0x00018100,
540        .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) |
541                       (MMU_TYPE_R4000 << CP0C0_MT),
542        .CP0_Config1 = MIPS_CONFIG1 | (31 << CP0C1_MMU) |
543                       (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) |
544                       (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) |
545                       (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
546        .CP0_Config2 = MIPS_CONFIG2,
547        .CP0_Config3 = MIPS_CONFIG3,
548        .CP0_LLAddr_rw_bitmask = 0,
549        .CP0_LLAddr_shift = 4,
550        .SYNCI_Step = 32,
551        .CCRes = 2,
552        .CP0_Status_rw_bitmask = 0x12F8FFFF,
553        .SEGBITS = 42,
554        .PABITS = 36,
555        .insn_flags = CPU_MIPS64R1,
556        .mmu_type = MMU_TYPE_R4000,
557    },
558    {
559        .name = "5Kf",
560        .CP0_PRid = 0x00018100,
561        .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) |
562                       (MMU_TYPE_R4000 << CP0C0_MT),
563        .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (31 << CP0C1_MMU) |
564                       (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) |
565                       (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) |
566                       (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
567        .CP0_Config2 = MIPS_CONFIG2,
568        .CP0_Config3 = MIPS_CONFIG3,
569        .CP0_LLAddr_rw_bitmask = 0,
570        .CP0_LLAddr_shift = 4,
571        .SYNCI_Step = 32,
572        .CCRes = 2,
573        .CP0_Status_rw_bitmask = 0x36F8FFFF,
574        /* The 5Kf has F64 / L / W but doesn't use the fcr0 bits. */
575        .CP1_fcr0 = (1 << FCR0_D) | (1 << FCR0_S) |
576                    (0x81 << FCR0_PRID) | (0x0 << FCR0_REV),
577        .CP1_fcr31 = 0,
578        .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
579        .SEGBITS = 42,
580        .PABITS = 36,
581        .insn_flags = CPU_MIPS64R1,
582        .mmu_type = MMU_TYPE_R4000,
583    },
584    {
585        .name = "20Kc",
586        /* We emulate a later version of the 20Kc, earlier ones had a broken
587           WAIT instruction. */
588        .CP0_PRid = 0x000182a0,
589        .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) |
590                    (MMU_TYPE_R4000 << CP0C0_MT) | (1 << CP0C0_VI),
591        .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (47 << CP0C1_MMU) |
592                       (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
593                       (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
594                       (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
595        .CP0_Config2 = MIPS_CONFIG2,
596        .CP0_Config3 = MIPS_CONFIG3,
597        .CP0_LLAddr_rw_bitmask = 0,
598        .CP0_LLAddr_shift = 0,
599        .SYNCI_Step = 32,
600        .CCRes = 1,
601        .CP0_Status_rw_bitmask = 0x36FBFFFF,
602        /* The 20Kc has F64 / L / W but doesn't use the fcr0 bits. */
603        .CP1_fcr0 = (1 << FCR0_3D) | (1 << FCR0_PS) |
604                    (1 << FCR0_D) | (1 << FCR0_S) |
605                    (0x82 << FCR0_PRID) | (0x0 << FCR0_REV),
606        .CP1_fcr31 = 0,
607        .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
608        .SEGBITS = 40,
609        .PABITS = 36,
610        .insn_flags = CPU_MIPS64R1 | ASE_MIPS3D,
611        .mmu_type = MMU_TYPE_R4000,
612    },
613    {
614        /* A generic CPU providing MIPS64 Release 2 features.
615           FIXME: Eventually this should be replaced by a real CPU model. */
616        .name = "MIPS64R2-generic",
617        .CP0_PRid = 0x00010000,
618        .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
619                       (MMU_TYPE_R4000 << CP0C0_MT),
620        .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) |
621                       (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
622                       (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
623                       (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
624        .CP0_Config2 = MIPS_CONFIG2,
625        .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA),
626        .CP0_LLAddr_rw_bitmask = 0,
627        .CP0_LLAddr_shift = 0,
628        .SYNCI_Step = 32,
629        .CCRes = 2,
630        .CP0_Status_rw_bitmask = 0x36FBFFFF,
631        .CP0_EBaseWG_rw_bitmask = (1 << CP0EBase_WG),
632        .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_3D) | (1 << FCR0_PS) |
633                    (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
634                    (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV),
635        .CP1_fcr31 = 0,
636        .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
637        .SEGBITS = 42,
638        .PABITS = 36,
639        .insn_flags = CPU_MIPS64R2 | ASE_MIPS3D,
640        .mmu_type = MMU_TYPE_R4000,
641    },
642    {
643        .name = "5KEc",
644        .CP0_PRid = 0x00018900,
645        .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
646                       (MMU_TYPE_R4000 << CP0C0_MT),
647        .CP0_Config1 = MIPS_CONFIG1 | (31 << CP0C1_MMU) |
648                       (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) |
649                       (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) |
650                       (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
651        .CP0_Config2 = MIPS_CONFIG2,
652        .CP0_Config3 = MIPS_CONFIG3,
653        .CP0_LLAddr_rw_bitmask = 0,
654        .CP0_LLAddr_shift = 4,
655        .SYNCI_Step = 32,
656        .CCRes = 2,
657        .CP0_Status_rw_bitmask = 0x12F8FFFF,
658        .SEGBITS = 42,
659        .PABITS = 36,
660        .insn_flags = CPU_MIPS64R2,
661        .mmu_type = MMU_TYPE_R4000,
662    },
663    {
664        .name = "5KEf",
665        .CP0_PRid = 0x00018900,
666        .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
667                       (MMU_TYPE_R4000 << CP0C0_MT),
668        .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (31 << CP0C1_MMU) |
669                       (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) |
670                       (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) |
671                       (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
672        .CP0_Config2 = MIPS_CONFIG2,
673        .CP0_Config3 = MIPS_CONFIG3,
674        .CP0_LLAddr_rw_bitmask = 0,
675        .CP0_LLAddr_shift = 4,
676        .SYNCI_Step = 32,
677        .CCRes = 2,
678        .CP0_Status_rw_bitmask = 0x36F8FFFF,
679        .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
680                    (1 << FCR0_D) | (1 << FCR0_S) |
681                    (0x89 << FCR0_PRID) | (0x0 << FCR0_REV),
682        .SEGBITS = 42,
683        .PABITS = 36,
684        .insn_flags = CPU_MIPS64R2,
685        .mmu_type = MMU_TYPE_R4000,
686    },
687    {
688        .name = "I6400",
689        .CP0_PRid = 0x1A900,
690        .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AR) | (0x2 << CP0C0_AT) |
691                       (MMU_TYPE_R4000 << CP0C0_MT),
692        .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
693                       (2 << CP0C1_IS) | (5 << CP0C1_IL) | (3 << CP0C1_IA) |
694                       (2 << CP0C1_DS) | (5 << CP0C1_DL) | (3 << CP0C1_DA) |
695                       (0 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
696        .CP0_Config2 = MIPS_CONFIG2,
697        .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) |
698                       (1 << CP0C3_CMGCR) | (1 << CP0C3_MSAP) |
699                       (1 << CP0C3_BP) | (1 << CP0C3_BI) | (1 << CP0C3_ULRI) |
700                       (1 << CP0C3_RXI) | (1 << CP0C3_LPA) | (1 << CP0C3_VInt),
701        .CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | (3 << CP0C4_IE) |
702                       (1 << CP0C4_AE) | (0xfc << CP0C4_KScrExist),
703        .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_XNP) | (1 << CP0C5_VP) |
704                       (1 << CP0C5_LLB) | (1 << CP0C5_MRP),
705        .CP0_Config5_rw_bitmask = (1 << CP0C5_MSAEn) | (1 << CP0C5_SBRI) |
706                                  (1 << CP0C5_FRE) | (1 << CP0C5_UFE),
707        .CP0_LLAddr_rw_bitmask = 0,
708        .CP0_LLAddr_shift = 0,
709        .SYNCI_Step = 32,
710        .CCRes = 2,
711        .CP0_Status_rw_bitmask = 0x30D8FFFF,
712        .CP0_PageGrain = (1 << CP0PG_IEC) | (1 << CP0PG_XIE) |
713                         (1U << CP0PG_RIE),
714        .CP0_PageGrain_rw_bitmask = (1 << CP0PG_ELPA),
715        .CP0_EBaseWG_rw_bitmask = (1 << CP0EBase_WG),
716        .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_HAS2008) | (1 << FCR0_F64) |
717                    (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
718                    (1 << FCR0_S) | (0x03 << FCR0_PRID) | (0x0 << FCR0_REV),
719        .CP1_fcr31 = (1 << FCR31_ABS2008) | (1 << FCR31_NAN2008),
720        .CP1_fcr31_rw_bitmask = 0x0103FFFF,
721        .MSAIR = 0x03 << MSAIR_ProcID,
722        .SEGBITS = 48,
723        .PABITS = 48,
724        .insn_flags = CPU_MIPS64R6,
725        .mmu_type = MMU_TYPE_R4000,
726    },
727    {
728        .name = "I6500",
729        .CP0_PRid = 0x1B000,
730        .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AR) | (0x2 << CP0C0_AT) |
731                       (MMU_TYPE_R4000 << CP0C0_MT),
732        .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
733                       (2 << CP0C1_IS) | (5 << CP0C1_IL) | (3 << CP0C1_IA) |
734                       (2 << CP0C1_DS) | (5 << CP0C1_DL) | (3 << CP0C1_DA) |
735                       (0 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
736        .CP0_Config2 = MIPS_CONFIG2,
737        .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) |
738                       (1 << CP0C3_CMGCR) | (1 << CP0C3_MSAP) |
739                       (1 << CP0C3_BP) | (1 << CP0C3_BI) | (1 << CP0C3_ULRI) |
740                       (1 << CP0C3_RXI) | (1 << CP0C3_LPA) | (1 << CP0C3_VInt),
741        .CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | (3 << CP0C4_IE) |
742                       (1 << CP0C4_AE) | (0xfc << CP0C4_KScrExist),
743        .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_XNP) | (1 << CP0C5_VP) |
744                       (1 << CP0C5_LLB) | (1 << CP0C5_MRP),
745        .CP0_Config5_rw_bitmask = (1 << CP0C5_MSAEn) | (1 << CP0C5_SBRI) |
746                                  (1 << CP0C5_FRE) | (1 << CP0C5_UFE),
747        .CP0_LLAddr_rw_bitmask = 0,
748        .CP0_LLAddr_shift = 0,
749        .SYNCI_Step = 64,
750        .CCRes = 2,
751        .CP0_Status_rw_bitmask = 0x30D8FFFF,
752        .CP0_PageGrain = (1 << CP0PG_IEC) | (1 << CP0PG_XIE) |
753                         (1U << CP0PG_RIE),
754        .CP0_PageGrain_rw_bitmask = (1 << CP0PG_ELPA),
755        .CP0_EBaseWG_rw_bitmask = (1 << CP0EBase_WG),
756        .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_HAS2008) | (1 << FCR0_F64) |
757                    (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
758                    (1 << FCR0_S) | (0x03 << FCR0_PRID) | (0x0 << FCR0_REV),
759        .CP1_fcr31 = (1 << FCR31_ABS2008) | (1 << FCR31_NAN2008),
760        .CP1_fcr31_rw_bitmask = 0x0103FFFF,
761        .MSAIR = 0x03 << MSAIR_ProcID,
762        .SEGBITS = 48,
763        .PABITS = 48,
764        .insn_flags = CPU_MIPS64R6,
765        .mmu_type = MMU_TYPE_R4000,
766    },
767    {
768        .name = "Loongson-2E",
769        .CP0_PRid = 0x6302,
770        /* 64KB I-cache and d-cache. 4 way with 32 bit cache line size.  */
771        .CP0_Config0 = (3 << CP0C0_Impl) | (4 << CP0C0_IC) | (4 << CP0C0_DC) |
772                       (1 << CP0C0_IB) | (1 << CP0C0_DB) | (0x2 << CP0C0_K0),
773        /* Note: Config1 is only used internally,
774           Loongson-2E has only Config0.  */
775        .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
776        .SYNCI_Step = 16,
777        .CCRes = 2,
778        .CP0_Status_rw_bitmask = 0x35D0FFFF,
779        .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x1 << FCR0_REV),
780        .CP1_fcr31 = 0,
781        .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
782        .SEGBITS = 40,
783        .PABITS = 40,
784        .insn_flags = CPU_MIPS3 | INSN_LOONGSON2E,
785        .mmu_type = MMU_TYPE_R4000,
786    },
787    {
788        .name = "Loongson-2F",
789        .CP0_PRid = 0x6303,
790        /* 64KB I-cache and d-cache. 4 way with 32 bit cache line size.  */
791        .CP0_Config0 = (3 << CP0C0_Impl) | (4 << CP0C0_IC) | (4 << CP0C0_DC) |
792                       (1 << CP0C0_IB) | (1 << CP0C0_DB) | (0x2 << CP0C0_K0),
793        /* Note: Config1 is only used internally,
794           Loongson-2F has only Config0.  */
795        .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
796        .SYNCI_Step = 16,
797        .CCRes = 2,
798        .CP0_Status_rw_bitmask = 0xF5D0FF1F,   /* Bits 7:5 not writable.  */
799        .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x1 << FCR0_REV),
800        .CP1_fcr31 = 0,
801        .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
802        .SEGBITS = 40,
803        .PABITS = 40,
804        .insn_flags = CPU_MIPS3 | INSN_LOONGSON2F | ASE_LMMI,
805        .mmu_type = MMU_TYPE_R4000,
806    },
807    {
808        .name = "Loongson-3A1000", /* Loongson-3A R1, GS464-based */
809        .CP0_PRid = 0x6305,
810        /* 64KB I-cache and d-cache. 4 way with 32 bit cache line size.  */
811        .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
812                       (MMU_TYPE_R4000 << CP0C0_MT),
813        .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) |
814                       (3 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
815                       (3 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
816                       (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
817        .CP0_Config2 = MIPS_CONFIG2 | (7 << CP0C2_SS) | (4 << CP0C2_SL) |
818                       (3 << CP0C2_SA),
819        .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA),
820        .CP0_LLAddr_rw_bitmask = 0,
821        .SYNCI_Step = 32,
822        .CCRes = 2,
823        .CP0_Status_rw_bitmask = 0x74D8FFFF,
824        .CP0_PageGrain = (1 << CP0PG_ELPA),
825        .CP0_PageGrain_rw_bitmask = (1 << CP0PG_ELPA),
826        .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x1 << FCR0_REV) | (0x1 << FCR0_F64) |
827                    (0x1 << FCR0_PS) | (0x1 << FCR0_L) | (0x1 << FCR0_W) |
828                    (0x1 << FCR0_D) | (0x1 << FCR0_S),
829        .CP1_fcr31 = 0,
830        .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
831        .SEGBITS = 48,
832        .PABITS = 48,
833        .insn_flags = CPU_MIPS64R2 | INSN_LOONGSON3A |
834                      ASE_LMMI | ASE_LEXT,
835        .mmu_type = MMU_TYPE_R4000,
836    },
837    {
838        .name = "Loongson-3A4000", /* Loongson-3A R4, GS464V-based */
839        .CP0_PRid = 0x14C000,
840        /* 64KB I-cache and d-cache. 4 way with 32 bit cache line size.  */
841        .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
842                       (MMU_TYPE_R4000 << CP0C0_MT),
843        .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) |
844                       (2 << CP0C1_IS) | (5 << CP0C1_IL) | (3 << CP0C1_IA) |
845                       (2 << CP0C1_DS) | (5 << CP0C1_DL) | (3 << CP0C1_DA) |
846                       (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
847        .CP0_Config2 = MIPS_CONFIG2 | (5 << CP0C2_SS) | (5 << CP0C2_SL) |
848                       (15 << CP0C2_SA),
849        .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) | (1 << CP0C3_MSAP) |
850                       (1 << CP0C3_BP) | (1 << CP0C3_BI) | (1 << CP0C3_ULRI) |
851                       (1 << CP0C3_RXI) | (1 << CP0C3_LPA) | (1 << CP0C3_VInt),
852        .CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | (2 << CP0C4_IE) |
853                       (1 << CP0C4_AE) | (0x1c << CP0C4_KScrExist),
854        .CP0_Config4_rw_bitmask = 0,
855        .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_CRCP) | (1 << CP0C5_NFExists),
856        .CP0_Config5_rw_bitmask = (1 << CP0C5_K) | (1 << CP0C5_CV) |
857                                  (1 << CP0C5_MSAEn) | (1 << CP0C5_UFE) |
858                                  (1 << CP0C5_FRE) | (1 << CP0C5_SBRI),
859        .CP0_Config6 = (1 << CP0C6_VCLRU) | (1 << CP0C6_DCLRU) |
860                       (1 << CP0C6_SFBEN) | (1 << CP0C6_VLTINT) |
861                       (1 << CP0C6_INSTPREF) | (1 << CP0C6_DATAPREF),
862        .CP0_Config6_rw_bitmask = (1 << CP0C6_BPPASS) | (0x3f << CP0C6_KPOS) |
863                       (1 << CP0C6_KE) | (1 << CP0C6_VTLBONLY) |
864                       (1 << CP0C6_LASX) | (1 << CP0C6_SSEN) |
865                       (1 << CP0C6_DISDRTIME) | (1 << CP0C6_PIXNUEN) |
866                       (1 << CP0C6_SCRAND) | (1 << CP0C6_LLEXCEN) |
867                       (1 << CP0C6_DISVC) | (1 << CP0C6_VCLRU) |
868                       (1 << CP0C6_DCLRU) | (1 << CP0C6_PIXUEN) |
869                       (1 << CP0C6_DISBLKLYEN) | (1 << CP0C6_UMEMUALEN) |
870                       (1 << CP0C6_SFBEN) | (1 << CP0C6_FLTINT) |
871                       (1 << CP0C6_VLTINT) | (1 << CP0C6_DISBTB) |
872                       (3 << CP0C6_STPREFCTL) | (1 << CP0C6_INSTPREF) |
873                       (1 << CP0C6_DATAPREF),
874        .CP0_Config7 = 0,
875        .CP0_Config7_rw_bitmask = (1 << CP0C7_NAPCGEN) | (1 << CP0C7_UNIMUEN) |
876                                  (1 << CP0C7_VFPUCGEN),
877        .CP0_LLAddr_rw_bitmask = 1,
878        .SYNCI_Step = 16,
879        .CCRes = 2,
880        .CP0_Status_rw_bitmask = 0x7DDBFFFF,
881        .CP0_PageGrain = (1 << CP0PG_ELPA),
882        .CP0_PageGrain_rw_bitmask = (1U << CP0PG_RIE) | (1 << CP0PG_XIE) |
883                    (1 << CP0PG_ELPA) | (1 << CP0PG_IEC),
884        .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x1 << FCR0_REV) | (0x1 << FCR0_F64) |
885                    (0x1 << FCR0_PS) | (0x1 << FCR0_L) | (0x1 << FCR0_W) |
886                    (0x1 << FCR0_D) | (0x1 << FCR0_S),
887        .CP1_fcr31 = 0,
888        .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
889        .SEGBITS = 48,
890        .PABITS = 48,
891        .insn_flags = CPU_MIPS64R2 | INSN_LOONGSON3A |
892                      ASE_LMMI | ASE_LEXT,
893        .mmu_type = MMU_TYPE_R4000,
894    },
895    {
896        /* A generic CPU providing MIPS64 DSP R2 ASE features.
897           FIXME: Eventually this should be replaced by a real CPU model. */
898        .name = "mips64dspr2",
899        .CP0_PRid = 0x00010000,
900        .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
901                       (MMU_TYPE_R4000 << CP0C0_MT),
902        .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) |
903                       (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
904                       (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
905                       (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
906        .CP0_Config2 = MIPS_CONFIG2,
907        .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) | (1 << CP0C3_DSP2P) |
908                       (1 << CP0C3_DSPP) | (1 << CP0C3_LPA),
909        .CP0_LLAddr_rw_bitmask = 0,
910        .CP0_LLAddr_shift = 0,
911        .SYNCI_Step = 32,
912        .CCRes = 2,
913        .CP0_Status_rw_bitmask = 0x37FBFFFF,
914        .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_3D) | (1 << FCR0_PS) |
915                    (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
916                    (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV),
917        .CP1_fcr31 = 0,
918        .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
919        .SEGBITS = 42,
920        .PABITS = 36,
921        .insn_flags = CPU_MIPS64R2 | ASE_DSP | ASE_DSP_R2,
922        .mmu_type = MMU_TYPE_R4000,
923    },
924
925#endif
926};
927const int mips_defs_number = ARRAY_SIZE(mips_defs);
928
929void mips_cpu_list(void)
930{
931    int i;
932
933    for (i = 0; i < ARRAY_SIZE(mips_defs); i++) {
934        qemu_printf("MIPS '%s'\n", mips_defs[i].name);
935    }
936}
937
938static void fpu_init (CPUMIPSState *env, const mips_def_t *def)
939{
940    int i;
941
942    for (i = 0; i < MIPS_FPU_MAX; i++)
943        env->fpus[i].fcr0 = def->CP1_fcr0;
944
945    memcpy(&env->active_fpu, &env->fpus[0], sizeof(env->active_fpu));
946}
947
948static void mvp_init(CPUMIPSState *env)
949{
950    env->mvp = g_malloc0(sizeof(CPUMIPSMVPContext));
951
952    if (!ase_mt_available(env)) {
953        return;
954    }
955
956    /* MVPConf1 implemented, TLB sharable, no gating storage support,
957       programmable cache partitioning implemented, number of allocatable
958       and shareable TLB entries, MVP has allocatable TCs, 2 VPEs
959       implemented, 5 TCs implemented. */
960    env->mvp->CP0_MVPConf0 = (1U << CP0MVPC0_M) | (1 << CP0MVPC0_TLBS) |
961                             (0 << CP0MVPC0_GS) | (1 << CP0MVPC0_PCP) |
962// TODO: actually do 2 VPEs.
963//                             (1 << CP0MVPC0_TCA) | (0x1 << CP0MVPC0_PVPE) |
964//                             (0x04 << CP0MVPC0_PTC);
965                             (1 << CP0MVPC0_TCA) | (0x0 << CP0MVPC0_PVPE) |
966                             (0x00 << CP0MVPC0_PTC);
967#if !defined(CONFIG_USER_ONLY)
968    /* Usermode has no TLB support */
969    env->mvp->CP0_MVPConf0 |= (env->tlb->nb_tlb << CP0MVPC0_PTLBE);
970#endif
971
972    /* Allocatable CP1 have media extensions, allocatable CP1 have FP support,
973       no UDI implemented, no CP2 implemented, 1 CP1 implemented. */
974    env->mvp->CP0_MVPConf1 = (1U << CP0MVPC1_CIM) | (1 << CP0MVPC1_CIF) |
975                             (0x0 << CP0MVPC1_PCX) | (0x0 << CP0MVPC1_PCP2) |
976                             (0x1 << CP0MVPC1_PCP1);
977}
978