]> Git Repo - qemu.git/blob - target-mips/translate_init.c
target-mips: add support for CP0_Config4
[qemu.git] / target-mips / translate_init.c
1 /*
2  *  MIPS emulation for qemu: CPU initialisation routines.
3  *
4  *  Copyright (c) 2004-2005 Jocelyn Mayer
5  *  Copyright (c) 2007 Herve Poussineau
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, 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   ((1 << 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 ((1 << 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 ((1 << 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 /* MMU types, the first four entries have the same layout as the
52    CP0C0_MT field.  */
53 enum mips_mmu_types {
54     MMU_TYPE_NONE,
55     MMU_TYPE_R4000,
56     MMU_TYPE_RESERVED,
57     MMU_TYPE_FMT,
58     MMU_TYPE_R3000,
59     MMU_TYPE_R6000,
60     MMU_TYPE_R8000
61 };
62
63 struct mips_def_t {
64     const char *name;
65     int32_t CP0_PRid;
66     int32_t CP0_Config0;
67     int32_t CP0_Config1;
68     int32_t CP0_Config2;
69     int32_t CP0_Config3;
70     int32_t CP0_Config4;
71     int32_t CP0_Config4_rw_bitmask;
72     int32_t CP0_Config6;
73     int32_t CP0_Config7;
74     target_ulong CP0_LLAddr_rw_bitmask;
75     int CP0_LLAddr_shift;
76     int32_t SYNCI_Step;
77     int32_t CCRes;
78     int32_t CP0_Status_rw_bitmask;
79     int32_t CP0_TCStatus_rw_bitmask;
80     int32_t CP0_SRSCtl;
81     int32_t CP1_fcr0;
82     int32_t SEGBITS;
83     int32_t PABITS;
84     int32_t CP0_SRSConf0_rw_bitmask;
85     int32_t CP0_SRSConf0;
86     int32_t CP0_SRSConf1_rw_bitmask;
87     int32_t CP0_SRSConf1;
88     int32_t CP0_SRSConf2_rw_bitmask;
89     int32_t CP0_SRSConf2;
90     int32_t CP0_SRSConf3_rw_bitmask;
91     int32_t CP0_SRSConf3;
92     int32_t CP0_SRSConf4_rw_bitmask;
93     int32_t CP0_SRSConf4;
94     int insn_flags;
95     enum mips_mmu_types mmu_type;
96 };
97
98 /*****************************************************************************/
99 /* MIPS CPU definitions */
100 static const mips_def_t mips_defs[] =
101 {
102     {
103         .name = "4Kc",
104         .CP0_PRid = 0x00018000,
105         .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_R4000 << CP0C0_MT),
106         .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
107                        (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
108                        (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
109                        (0 << CP0C1_CA),
110         .CP0_Config2 = MIPS_CONFIG2,
111         .CP0_Config3 = MIPS_CONFIG3,
112         .CP0_LLAddr_rw_bitmask = 0,
113         .CP0_LLAddr_shift = 4,
114         .SYNCI_Step = 32,
115         .CCRes = 2,
116         .CP0_Status_rw_bitmask = 0x1278FF17,
117         .SEGBITS = 32,
118         .PABITS = 32,
119         .insn_flags = CPU_MIPS32,
120         .mmu_type = MMU_TYPE_R4000,
121     },
122     {
123         .name = "4Km",
124         .CP0_PRid = 0x00018300,
125         /* Config1 implemented, fixed mapping MMU,
126            no virtual icache, uncached coherency. */
127         .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_FMT << CP0C0_MT),
128         .CP0_Config1 = MIPS_CONFIG1 |
129                        (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
130                        (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
131                        (1 << CP0C1_CA),
132         .CP0_Config2 = MIPS_CONFIG2,
133         .CP0_Config3 = MIPS_CONFIG3,
134         .CP0_LLAddr_rw_bitmask = 0,
135         .CP0_LLAddr_shift = 4,
136         .SYNCI_Step = 32,
137         .CCRes = 2,
138         .CP0_Status_rw_bitmask = 0x1258FF17,
139         .SEGBITS = 32,
140         .PABITS = 32,
141         .insn_flags = CPU_MIPS32 | ASE_MIPS16,
142         .mmu_type = MMU_TYPE_FMT,
143     },
144     {
145         .name = "4KEcR1",
146         .CP0_PRid = 0x00018400,
147         .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_R4000 << CP0C0_MT),
148         .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
149                        (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
150                        (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
151                        (0 << CP0C1_CA),
152         .CP0_Config2 = MIPS_CONFIG2,
153         .CP0_Config3 = MIPS_CONFIG3,
154         .CP0_LLAddr_rw_bitmask = 0,
155         .CP0_LLAddr_shift = 4,
156         .SYNCI_Step = 32,
157         .CCRes = 2,
158         .CP0_Status_rw_bitmask = 0x1278FF17,
159         .SEGBITS = 32,
160         .PABITS = 32,
161         .insn_flags = CPU_MIPS32,
162         .mmu_type = MMU_TYPE_R4000,
163     },
164     {
165         .name = "4KEmR1",
166         .CP0_PRid = 0x00018500,
167         .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_FMT << CP0C0_MT),
168         .CP0_Config1 = MIPS_CONFIG1 |
169                        (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
170                        (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
171                        (1 << CP0C1_CA),
172         .CP0_Config2 = MIPS_CONFIG2,
173         .CP0_Config3 = MIPS_CONFIG3,
174         .CP0_LLAddr_rw_bitmask = 0,
175         .CP0_LLAddr_shift = 4,
176         .SYNCI_Step = 32,
177         .CCRes = 2,
178         .CP0_Status_rw_bitmask = 0x1258FF17,
179         .SEGBITS = 32,
180         .PABITS = 32,
181         .insn_flags = CPU_MIPS32 | ASE_MIPS16,
182         .mmu_type = MMU_TYPE_FMT,
183     },
184     {
185         .name = "4KEc",
186         .CP0_PRid = 0x00019000,
187         .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
188                     (MMU_TYPE_R4000 << CP0C0_MT),
189         .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
190                        (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
191                        (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
192                        (0 << CP0C1_CA),
193         .CP0_Config2 = MIPS_CONFIG2,
194         .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
195         .CP0_LLAddr_rw_bitmask = 0,
196         .CP0_LLAddr_shift = 4,
197         .SYNCI_Step = 32,
198         .CCRes = 2,
199         .CP0_Status_rw_bitmask = 0x1278FF17,
200         .SEGBITS = 32,
201         .PABITS = 32,
202         .insn_flags = CPU_MIPS32R2,
203         .mmu_type = MMU_TYPE_R4000,
204     },
205     {
206         .name = "4KEm",
207         .CP0_PRid = 0x00019100,
208         .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
209                        (MMU_TYPE_FMT << CP0C0_MT),
210         .CP0_Config1 = MIPS_CONFIG1 |
211                        (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
212                        (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
213                        (1 << CP0C1_CA),
214         .CP0_Config2 = MIPS_CONFIG2,
215         .CP0_Config3 = MIPS_CONFIG3,
216         .CP0_LLAddr_rw_bitmask = 0,
217         .CP0_LLAddr_shift = 4,
218         .SYNCI_Step = 32,
219         .CCRes = 2,
220         .CP0_Status_rw_bitmask = 0x1258FF17,
221         .SEGBITS = 32,
222         .PABITS = 32,
223         .insn_flags = CPU_MIPS32R2 | ASE_MIPS16,
224         .mmu_type = MMU_TYPE_FMT,
225     },
226     {
227         .name = "24Kc",
228         .CP0_PRid = 0x00019300,
229         .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
230                        (MMU_TYPE_R4000 << CP0C0_MT),
231         .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
232                        (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
233                        (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
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 = 0x1278FF1F,
243         .SEGBITS = 32,
244         .PABITS = 32,
245         .insn_flags = CPU_MIPS32R2 | ASE_MIPS16,
246         .mmu_type = MMU_TYPE_R4000,
247     },
248     {
249         .name = "24Kf",
250         .CP0_PRid = 0x00019300,
251         .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
252                     (MMU_TYPE_R4000 << CP0C0_MT),
253         .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
254                        (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
255                        (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
256                        (1 << CP0C1_CA),
257         .CP0_Config2 = MIPS_CONFIG2,
258         .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
259         .CP0_LLAddr_rw_bitmask = 0,
260         .CP0_LLAddr_shift = 4,
261         .SYNCI_Step = 32,
262         .CCRes = 2,
263         /* No DSP implemented. */
264         .CP0_Status_rw_bitmask = 0x3678FF1F,
265         .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
266                     (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID),
267         .SEGBITS = 32,
268         .PABITS = 32,
269         .insn_flags = CPU_MIPS32R2 | ASE_MIPS16,
270         .mmu_type = MMU_TYPE_R4000,
271     },
272     {
273         .name = "34Kf",
274         .CP0_PRid = 0x00019500,
275         .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
276                        (MMU_TYPE_R4000 << CP0C0_MT),
277         .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
278                        (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
279                        (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
280                        (1 << CP0C1_CA),
281         .CP0_Config2 = MIPS_CONFIG2,
282         .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_VInt) | (1 << CP0C3_MT) |
283                        (1 << CP0C3_DSPP),
284         .CP0_LLAddr_rw_bitmask = 0,
285         .CP0_LLAddr_shift = 0,
286         .SYNCI_Step = 32,
287         .CCRes = 2,
288         .CP0_Status_rw_bitmask = 0x3778FF1F,
289         .CP0_TCStatus_rw_bitmask = (0 << CP0TCSt_TCU3) | (0 << CP0TCSt_TCU2) |
290                     (1 << CP0TCSt_TCU1) | (1 << CP0TCSt_TCU0) |
291                     (0 << CP0TCSt_TMX) | (1 << CP0TCSt_DT) |
292                     (1 << CP0TCSt_DA) | (1 << CP0TCSt_A) |
293                     (0x3 << CP0TCSt_TKSU) | (1 << CP0TCSt_IXMT) |
294                     (0xff << CP0TCSt_TASID),
295         .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
296                     (1 << FCR0_D) | (1 << FCR0_S) | (0x95 << FCR0_PRID),
297         .CP0_SRSCtl = (0xf << CP0SRSCtl_HSS),
298         .CP0_SRSConf0_rw_bitmask = 0x3fffffff,
299         .CP0_SRSConf0 = (1 << CP0SRSC0_M) | (0x3fe << CP0SRSC0_SRS3) |
300                     (0x3fe << CP0SRSC0_SRS2) | (0x3fe << CP0SRSC0_SRS1),
301         .CP0_SRSConf1_rw_bitmask = 0x3fffffff,
302         .CP0_SRSConf1 = (1 << CP0SRSC1_M) | (0x3fe << CP0SRSC1_SRS6) |
303                     (0x3fe << CP0SRSC1_SRS5) | (0x3fe << CP0SRSC1_SRS4),
304         .CP0_SRSConf2_rw_bitmask = 0x3fffffff,
305         .CP0_SRSConf2 = (1 << CP0SRSC2_M) | (0x3fe << CP0SRSC2_SRS9) |
306                     (0x3fe << CP0SRSC2_SRS8) | (0x3fe << CP0SRSC2_SRS7),
307         .CP0_SRSConf3_rw_bitmask = 0x3fffffff,
308         .CP0_SRSConf3 = (1 << CP0SRSC3_M) | (0x3fe << CP0SRSC3_SRS12) |
309                     (0x3fe << CP0SRSC3_SRS11) | (0x3fe << CP0SRSC3_SRS10),
310         .CP0_SRSConf4_rw_bitmask = 0x3fffffff,
311         .CP0_SRSConf4 = (0x3fe << CP0SRSC4_SRS15) |
312                     (0x3fe << CP0SRSC4_SRS14) | (0x3fe << CP0SRSC4_SRS13),
313         .SEGBITS = 32,
314         .PABITS = 32,
315         .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_MT,
316         .mmu_type = MMU_TYPE_R4000,
317     },
318     {
319         .name = "74Kf",
320         .CP0_PRid = 0x00019700,
321         .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
322                     (MMU_TYPE_R4000 << CP0C0_MT),
323         .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
324                        (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
325                        (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
326                        (1 << CP0C1_CA),
327         .CP0_Config2 = MIPS_CONFIG2,
328         .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt) | (1 << CP0C3_DSPP),
329         .CP0_LLAddr_rw_bitmask = 0,
330         .CP0_LLAddr_shift = 4,
331         .SYNCI_Step = 32,
332         .CCRes = 2,
333         .CP0_Status_rw_bitmask = 0x3778FF1F,
334         .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
335                     (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID),
336         .SEGBITS = 32,
337         .PABITS = 32,
338         .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_DSPR2,
339         .mmu_type = MMU_TYPE_R4000,
340     },
341     {
342         /* A generic CPU providing MIPS32 Release 5 features.
343            FIXME: Eventually this should be replaced by a real CPU model. */
344         .name = "mips32r5-generic",
345         .CP0_PRid = 0x00019700,
346         .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
347                     (MMU_TYPE_R4000 << CP0C0_MT),
348         .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) |
349                        (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) |
350                        (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) |
351                        (1 << CP0C1_CA),
352         .CP0_Config2 = MIPS_CONFIG2,
353         .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_M),
354         .CP0_Config4 = MIPS_CONFIG4,
355         .CP0_Config4_rw_bitmask = 0,
356         .CP0_LLAddr_rw_bitmask = 0,
357         .CP0_LLAddr_shift = 4,
358         .SYNCI_Step = 32,
359         .CCRes = 2,
360         .CP0_Status_rw_bitmask = 0x3778FF1F,
361         .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) |
362                     (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID),
363         .SEGBITS = 32,
364         .PABITS = 32,
365         .insn_flags = CPU_MIPS32R5 | ASE_MIPS16 | ASE_DSP | ASE_DSPR2,
366         .mmu_type = MMU_TYPE_R4000,
367     },
368 #if defined(TARGET_MIPS64)
369     {
370         .name = "R4000",
371         .CP0_PRid = 0x00000400,
372         /* No L2 cache, icache size 8k, dcache size 8k, uncached coherency. */
373         .CP0_Config0 = (1 << 17) | (0x1 << 9) | (0x1 << 6) | (0x2 << CP0C0_K0),
374         /* Note: Config1 is only used internally, the R4000 has only Config0. */
375         .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
376         .CP0_LLAddr_rw_bitmask = 0xFFFFFFFF,
377         .CP0_LLAddr_shift = 4,
378         .SYNCI_Step = 16,
379         .CCRes = 2,
380         .CP0_Status_rw_bitmask = 0x3678FFFF,
381         /* The R4000 has a full 64bit FPU but doesn't use the fcr0 bits. */
382         .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x0 << FCR0_REV),
383         .SEGBITS = 40,
384         .PABITS = 36,
385         .insn_flags = CPU_MIPS3,
386         .mmu_type = MMU_TYPE_R4000,
387     },
388     {
389         .name = "VR5432",
390         .CP0_PRid = 0x00005400,
391         /* No L2 cache, icache size 8k, dcache size 8k, uncached coherency. */
392         .CP0_Config0 = (1 << 17) | (0x1 << 9) | (0x1 << 6) | (0x2 << CP0C0_K0),
393         .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
394         .CP0_LLAddr_rw_bitmask = 0xFFFFFFFFL,
395         .CP0_LLAddr_shift = 4,
396         .SYNCI_Step = 16,
397         .CCRes = 2,
398         .CP0_Status_rw_bitmask = 0x3678FFFF,
399         /* The VR5432 has a full 64bit FPU but doesn't use the fcr0 bits. */
400         .CP1_fcr0 = (0x54 << FCR0_PRID) | (0x0 << FCR0_REV),
401         .SEGBITS = 40,
402         .PABITS = 32,
403         .insn_flags = CPU_VR54XX,
404         .mmu_type = MMU_TYPE_R4000,
405     },
406     {
407         .name = "5Kc",
408         .CP0_PRid = 0x00018100,
409         .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) |
410                        (MMU_TYPE_R4000 << CP0C0_MT),
411         .CP0_Config1 = MIPS_CONFIG1 | (31 << CP0C1_MMU) |
412                        (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) |
413                        (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) |
414                        (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
415         .CP0_Config2 = MIPS_CONFIG2,
416         .CP0_Config3 = MIPS_CONFIG3,
417         .CP0_LLAddr_rw_bitmask = 0,
418         .CP0_LLAddr_shift = 4,
419         .SYNCI_Step = 32,
420         .CCRes = 2,
421         .CP0_Status_rw_bitmask = 0x32F8FFFF,
422         .SEGBITS = 42,
423         .PABITS = 36,
424         .insn_flags = CPU_MIPS64,
425         .mmu_type = MMU_TYPE_R4000,
426     },
427     {
428         .name = "5Kf",
429         .CP0_PRid = 0x00018100,
430         .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) |
431                        (MMU_TYPE_R4000 << CP0C0_MT),
432         .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (31 << CP0C1_MMU) |
433                        (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) |
434                        (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) |
435                        (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
436         .CP0_Config2 = MIPS_CONFIG2,
437         .CP0_Config3 = MIPS_CONFIG3,
438         .CP0_LLAddr_rw_bitmask = 0,
439         .CP0_LLAddr_shift = 4,
440         .SYNCI_Step = 32,
441         .CCRes = 2,
442         .CP0_Status_rw_bitmask = 0x36F8FFFF,
443         /* The 5Kf has F64 / L / W but doesn't use the fcr0 bits. */
444         .CP1_fcr0 = (1 << FCR0_D) | (1 << FCR0_S) |
445                     (0x81 << FCR0_PRID) | (0x0 << FCR0_REV),
446         .SEGBITS = 42,
447         .PABITS = 36,
448         .insn_flags = CPU_MIPS64,
449         .mmu_type = MMU_TYPE_R4000,
450     },
451     {
452         .name = "20Kc",
453         /* We emulate a later version of the 20Kc, earlier ones had a broken
454            WAIT instruction. */
455         .CP0_PRid = 0x000182a0,
456         .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) |
457                     (MMU_TYPE_R4000 << CP0C0_MT) | (1 << CP0C0_VI),
458         .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (47 << CP0C1_MMU) |
459                        (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
460                        (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
461                        (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
462         .CP0_Config2 = MIPS_CONFIG2,
463         .CP0_Config3 = MIPS_CONFIG3,
464         .CP0_LLAddr_rw_bitmask = 0,
465         .CP0_LLAddr_shift = 0,
466         .SYNCI_Step = 32,
467         .CCRes = 1,
468         .CP0_Status_rw_bitmask = 0x36FBFFFF,
469         /* The 20Kc has F64 / L / W but doesn't use the fcr0 bits. */
470         .CP1_fcr0 = (1 << FCR0_3D) | (1 << FCR0_PS) |
471                     (1 << FCR0_D) | (1 << FCR0_S) |
472                     (0x82 << FCR0_PRID) | (0x0 << FCR0_REV),
473         .SEGBITS = 40,
474         .PABITS = 36,
475         .insn_flags = CPU_MIPS64 | ASE_MIPS3D,
476         .mmu_type = MMU_TYPE_R4000,
477     },
478     {
479         /* A generic CPU providing MIPS64 Release 2 features.
480            FIXME: Eventually this should be replaced by a real CPU model. */
481         .name = "MIPS64R2-generic",
482         .CP0_PRid = 0x00010000,
483         .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
484                        (MMU_TYPE_R4000 << CP0C0_MT),
485         .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) |
486                        (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
487                        (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
488                        (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
489         .CP0_Config2 = MIPS_CONFIG2,
490         .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA),
491         .CP0_LLAddr_rw_bitmask = 0,
492         .CP0_LLAddr_shift = 0,
493         .SYNCI_Step = 32,
494         .CCRes = 2,
495         .CP0_Status_rw_bitmask = 0x36FBFFFF,
496         .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_3D) | (1 << FCR0_PS) |
497                     (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
498                     (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV),
499         .SEGBITS = 42,
500         /* The architectural limit is 59, but we have hardcoded 36 bit
501            in some places...
502         .PABITS = 59, */ /* the architectural limit */
503         .PABITS = 36,
504         .insn_flags = CPU_MIPS64R2 | ASE_MIPS3D,
505         .mmu_type = MMU_TYPE_R4000,
506     },
507     {
508         .name = "Loongson-2E",
509         .CP0_PRid = 0x6302,
510         /*64KB I-cache and d-cache. 4 way with 32 bit cache line size*/
511         .CP0_Config0 = (0x1<<17) | (0x1<<16) | (0x1<<11) | (0x1<<8) | (0x1<<5) |
512                        (0x1<<4) | (0x1<<1),
513         /* Note: Config1 is only used internally, Loongson-2E has only Config0. */
514         .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
515         .SYNCI_Step = 16,
516         .CCRes = 2,
517         .CP0_Status_rw_bitmask = 0x35D0FFFF,
518         .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x1 << FCR0_REV),
519         .SEGBITS = 40,
520         .PABITS = 40,
521         .insn_flags = CPU_LOONGSON2E,
522         .mmu_type = MMU_TYPE_R4000,
523     },
524     {
525       .name = "Loongson-2F",
526       .CP0_PRid = 0x6303,
527       /*64KB I-cache and d-cache. 4 way with 32 bit cache line size*/
528       .CP0_Config0 = (0x1<<17) | (0x1<<16) | (0x1<<11) | (0x1<<8) | (0x1<<5) |
529                      (0x1<<4) | (0x1<<1),
530       /* Note: Config1 is only used internally, Loongson-2F has only Config0. */
531       .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU),
532       .SYNCI_Step = 16,
533       .CCRes = 2,
534       .CP0_Status_rw_bitmask = 0xF5D0FF1F,   /*bit5:7 not writable*/
535       .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x1 << FCR0_REV),
536       .SEGBITS = 40,
537       .PABITS = 40,
538       .insn_flags = CPU_LOONGSON2F,
539       .mmu_type = MMU_TYPE_R4000,
540     },
541     {
542         /* A generic CPU providing MIPS64 ASE DSP 2 features.
543            FIXME: Eventually this should be replaced by a real CPU model. */
544         .name = "mips64dspr2",
545         .CP0_PRid = 0x00010000,
546         .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) |
547                        (MMU_TYPE_R4000 << CP0C0_MT),
548         .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) |
549                        (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) |
550                        (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
551                        (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
552         .CP0_Config2 = MIPS_CONFIG2,
553         .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA),
554         .CP0_LLAddr_rw_bitmask = 0,
555         .CP0_LLAddr_shift = 0,
556         .SYNCI_Step = 32,
557         .CCRes = 2,
558         .CP0_Status_rw_bitmask = 0x37FBFFFF,
559         .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_3D) | (1 << FCR0_PS) |
560                     (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) |
561                     (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV),
562         .SEGBITS = 42,
563         /* The architectural limit is 59, but we have hardcoded 36 bit
564            in some places...
565         .PABITS = 59, */ /* the architectural limit */
566         .PABITS = 36,
567         .insn_flags = CPU_MIPS64R2 | ASE_DSP | ASE_DSPR2,
568         .mmu_type = MMU_TYPE_R4000,
569     },
570
571 #endif
572 };
573
574 static const mips_def_t *cpu_mips_find_by_name (const char *name)
575 {
576     int i;
577
578     for (i = 0; i < ARRAY_SIZE(mips_defs); i++) {
579         if (strcasecmp(name, mips_defs[i].name) == 0) {
580             return &mips_defs[i];
581         }
582     }
583     return NULL;
584 }
585
586 void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf)
587 {
588     int i;
589
590     for (i = 0; i < ARRAY_SIZE(mips_defs); i++) {
591         (*cpu_fprintf)(f, "MIPS '%s'\n",
592                        mips_defs[i].name);
593     }
594 }
595
596 #ifndef CONFIG_USER_ONLY
597 static void no_mmu_init (CPUMIPSState *env, const mips_def_t *def)
598 {
599     env->tlb->nb_tlb = 1;
600     env->tlb->map_address = &no_mmu_map_address;
601 }
602
603 static void fixed_mmu_init (CPUMIPSState *env, const mips_def_t *def)
604 {
605     env->tlb->nb_tlb = 1;
606     env->tlb->map_address = &fixed_mmu_map_address;
607 }
608
609 static void r4k_mmu_init (CPUMIPSState *env, const mips_def_t *def)
610 {
611     env->tlb->nb_tlb = 1 + ((def->CP0_Config1 >> CP0C1_MMU) & 63);
612     env->tlb->map_address = &r4k_map_address;
613     env->tlb->helper_tlbwi = r4k_helper_tlbwi;
614     env->tlb->helper_tlbwr = r4k_helper_tlbwr;
615     env->tlb->helper_tlbp = r4k_helper_tlbp;
616     env->tlb->helper_tlbr = r4k_helper_tlbr;
617 }
618
619 static void mmu_init (CPUMIPSState *env, const mips_def_t *def)
620 {
621     env->tlb = g_malloc0(sizeof(CPUMIPSTLBContext));
622
623     switch (def->mmu_type) {
624         case MMU_TYPE_NONE:
625             no_mmu_init(env, def);
626             break;
627         case MMU_TYPE_R4000:
628             r4k_mmu_init(env, def);
629             break;
630         case MMU_TYPE_FMT:
631             fixed_mmu_init(env, def);
632             break;
633         case MMU_TYPE_R3000:
634         case MMU_TYPE_R6000:
635         case MMU_TYPE_R8000:
636         default:
637             cpu_abort(env, "MMU type not supported\n");
638     }
639 }
640 #endif /* CONFIG_USER_ONLY */
641
642 static void fpu_init (CPUMIPSState *env, const mips_def_t *def)
643 {
644     int i;
645
646     for (i = 0; i < MIPS_FPU_MAX; i++)
647         env->fpus[i].fcr0 = def->CP1_fcr0;
648
649     memcpy(&env->active_fpu, &env->fpus[0], sizeof(env->active_fpu));
650 }
651
652 static void mvp_init (CPUMIPSState *env, const mips_def_t *def)
653 {
654     env->mvp = g_malloc0(sizeof(CPUMIPSMVPContext));
655
656     /* MVPConf1 implemented, TLB sharable, no gating storage support,
657        programmable cache partitioning implemented, number of allocatable
658        and sharable TLB entries, MVP has allocatable TCs, 2 VPEs
659        implemented, 5 TCs implemented. */
660     env->mvp->CP0_MVPConf0 = (1 << CP0MVPC0_M) | (1 << CP0MVPC0_TLBS) |
661                              (0 << CP0MVPC0_GS) | (1 << CP0MVPC0_PCP) |
662 // TODO: actually do 2 VPEs.
663 //                             (1 << CP0MVPC0_TCA) | (0x1 << CP0MVPC0_PVPE) |
664 //                             (0x04 << CP0MVPC0_PTC);
665                              (1 << CP0MVPC0_TCA) | (0x0 << CP0MVPC0_PVPE) |
666                              (0x00 << CP0MVPC0_PTC);
667 #if !defined(CONFIG_USER_ONLY)
668     /* Usermode has no TLB support */
669     env->mvp->CP0_MVPConf0 |= (env->tlb->nb_tlb << CP0MVPC0_PTLBE);
670 #endif
671
672     /* Allocatable CP1 have media extensions, allocatable CP1 have FP support,
673        no UDI implemented, no CP2 implemented, 1 CP1 implemented. */
674     env->mvp->CP0_MVPConf1 = (1 << CP0MVPC1_CIM) | (1 << CP0MVPC1_CIF) |
675                              (0x0 << CP0MVPC1_PCX) | (0x0 << CP0MVPC1_PCP2) |
676                              (0x1 << CP0MVPC1_PCP1);
677 }
This page took 0.064836 seconds and 4 git commands to generate.