]>
Commit | Line | Data |
---|---|---|
33d68b5f TS |
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 | |
8167ee88 | 18 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
33d68b5f TS |
19 | */ |
20 | ||
3953d786 TS |
21 | /* CPU / CPU family specific config register values. */ |
22 | ||
6d35524c | 23 | /* Have config1, uncached coherency */ |
3953d786 | 24 | #define MIPS_CONFIG0 \ |
f45cb2f4 | 25 | ((1U << CP0C0_M) | (0x2 << CP0C0_K0)) |
3953d786 | 26 | |
ae5d8053 | 27 | /* Have config2, no coprocessor2 attached, no MDMX support attached, |
3953d786 TS |
28 | no performance counters, watch registers present, |
29 | no code compression, EJTAG present, no FPU */ | |
30 | #define MIPS_CONFIG1 \ | |
f45cb2f4 | 31 | ((1U << CP0C1_M) | \ |
3953d786 TS |
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 \ | |
f45cb2f4 | 38 | ((1U << CP0C2_M)) |
3953d786 | 39 | |
6d35524c | 40 | /* No config4, no DSP ASE, no large physaddr (PABITS), |
ff2712ba | 41 | no external interrupt controller, no vectored interrupts, |
ead9360e | 42 | no 1kb pages, no SmartMIPS ASE, no trace logic */ |
3953d786 TS |
43 | #define MIPS_CONFIG3 \ |
44 | ((0 << CP0C3_M) | (0 << CP0C3_DSPP) | (0 << CP0C3_LPA) | \ | |
45 | (0 << CP0C3_VEIC) | (0 << CP0C3_VInt) | (0 << CP0C3_SP) | \ | |
ead9360e | 46 | (0 << CP0C3_SM) | (0 << CP0C3_TL)) |
3953d786 | 47 | |
b4160af1 PJ |
48 | #define MIPS_CONFIG4 \ |
49 | ((0 << CP0C4_M)) | |
50 | ||
b4dd99a3 PJ |
51 | #define MIPS_CONFIG5 \ |
52 | ((0 << CP0C5_M)) | |
53 | ||
6d35524c TS |
54 | /* MMU types, the first four entries have the same layout as the |
55 | CP0C0_MT field. */ | |
56 | enum mips_mmu_types { | |
57 | MMU_TYPE_NONE, | |
58 | MMU_TYPE_R4000, | |
59 | MMU_TYPE_RESERVED, | |
60 | MMU_TYPE_FMT, | |
61 | MMU_TYPE_R3000, | |
62 | MMU_TYPE_R6000, | |
63 | MMU_TYPE_R8000 | |
64 | }; | |
65 | ||
c227f099 | 66 | struct mips_def_t { |
50366fe9 | 67 | const char *name; |
33d68b5f TS |
68 | int32_t CP0_PRid; |
69 | int32_t CP0_Config0; | |
70 | int32_t CP0_Config1; | |
3953d786 TS |
71 | int32_t CP0_Config2; |
72 | int32_t CP0_Config3; | |
b4160af1 PJ |
73 | int32_t CP0_Config4; |
74 | int32_t CP0_Config4_rw_bitmask; | |
b4dd99a3 PJ |
75 | int32_t CP0_Config5; |
76 | int32_t CP0_Config5_rw_bitmask; | |
34ee2ede TS |
77 | int32_t CP0_Config6; |
78 | int32_t CP0_Config7; | |
2a6e32dd AJ |
79 | target_ulong CP0_LLAddr_rw_bitmask; |
80 | int CP0_LLAddr_shift; | |
2f644545 TS |
81 | int32_t SYNCI_Step; |
82 | int32_t CCRes; | |
ead9360e TS |
83 | int32_t CP0_Status_rw_bitmask; |
84 | int32_t CP0_TCStatus_rw_bitmask; | |
85 | int32_t CP0_SRSCtl; | |
3953d786 | 86 | int32_t CP1_fcr0; |
863f264d | 87 | int32_t MSAIR; |
e034e2c3 | 88 | int32_t SEGBITS; |
6d35524c | 89 | int32_t PABITS; |
ead9360e TS |
90 | int32_t CP0_SRSConf0_rw_bitmask; |
91 | int32_t CP0_SRSConf0; | |
92 | int32_t CP0_SRSConf1_rw_bitmask; | |
93 | int32_t CP0_SRSConf1; | |
94 | int32_t CP0_SRSConf2_rw_bitmask; | |
95 | int32_t CP0_SRSConf2; | |
96 | int32_t CP0_SRSConf3_rw_bitmask; | |
97 | int32_t CP0_SRSConf3; | |
98 | int32_t CP0_SRSConf4_rw_bitmask; | |
99 | int32_t CP0_SRSConf4; | |
7207c7f9 LA |
100 | int32_t CP0_PageGrain_rw_bitmask; |
101 | int32_t CP0_PageGrain; | |
e189e748 | 102 | int insn_flags; |
6d35524c | 103 | enum mips_mmu_types mmu_type; |
33d68b5f TS |
104 | }; |
105 | ||
106 | /*****************************************************************************/ | |
107 | /* MIPS CPU definitions */ | |
c227f099 | 108 | static const mips_def_t mips_defs[] = |
33d68b5f | 109 | { |
33d68b5f TS |
110 | { |
111 | .name = "4Kc", | |
112 | .CP0_PRid = 0x00018000, | |
6d35524c | 113 | .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_R4000 << CP0C0_MT), |
ae5d8053 | 114 | .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) | |
6958549d | 115 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
d19954f4 | 116 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) | |
ab3aee26 | 117 | (0 << CP0C1_CA), |
3953d786 TS |
118 | .CP0_Config2 = MIPS_CONFIG2, |
119 | .CP0_Config3 = MIPS_CONFIG3, | |
2a6e32dd AJ |
120 | .CP0_LLAddr_rw_bitmask = 0, |
121 | .CP0_LLAddr_shift = 4, | |
2f644545 TS |
122 | .SYNCI_Step = 32, |
123 | .CCRes = 2, | |
ead9360e | 124 | .CP0_Status_rw_bitmask = 0x1278FF17, |
6d35524c TS |
125 | .SEGBITS = 32, |
126 | .PABITS = 32, | |
73642f5b | 127 | .insn_flags = CPU_MIPS32, |
6d35524c | 128 | .mmu_type = MMU_TYPE_R4000, |
33d68b5f | 129 | }, |
8d162c2b TS |
130 | { |
131 | .name = "4Km", | |
132 | .CP0_PRid = 0x00018300, | |
133 | /* Config1 implemented, fixed mapping MMU, | |
134 | no virtual icache, uncached coherency. */ | |
6d35524c | 135 | .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_FMT << CP0C0_MT), |
8d162c2b | 136 | .CP0_Config1 = MIPS_CONFIG1 | |
6958549d | 137 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
d19954f4 NF |
138 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) | |
139 | (1 << CP0C1_CA), | |
8d162c2b TS |
140 | .CP0_Config2 = MIPS_CONFIG2, |
141 | .CP0_Config3 = MIPS_CONFIG3, | |
2a6e32dd AJ |
142 | .CP0_LLAddr_rw_bitmask = 0, |
143 | .CP0_LLAddr_shift = 4, | |
8d162c2b TS |
144 | .SYNCI_Step = 32, |
145 | .CCRes = 2, | |
146 | .CP0_Status_rw_bitmask = 0x1258FF17, | |
6d35524c TS |
147 | .SEGBITS = 32, |
148 | .PABITS = 32, | |
8d162c2b | 149 | .insn_flags = CPU_MIPS32 | ASE_MIPS16, |
6d35524c | 150 | .mmu_type = MMU_TYPE_FMT, |
8d162c2b | 151 | }, |
33d68b5f | 152 | { |
34ee2ede | 153 | .name = "4KEcR1", |
33d68b5f | 154 | .CP0_PRid = 0x00018400, |
6d35524c | 155 | .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_R4000 << CP0C0_MT), |
ae5d8053 | 156 | .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) | |
6958549d | 157 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
d19954f4 | 158 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) | |
ab3aee26 | 159 | (0 << CP0C1_CA), |
34ee2ede TS |
160 | .CP0_Config2 = MIPS_CONFIG2, |
161 | .CP0_Config3 = MIPS_CONFIG3, | |
2a6e32dd AJ |
162 | .CP0_LLAddr_rw_bitmask = 0, |
163 | .CP0_LLAddr_shift = 4, | |
2f644545 TS |
164 | .SYNCI_Step = 32, |
165 | .CCRes = 2, | |
ead9360e | 166 | .CP0_Status_rw_bitmask = 0x1278FF17, |
6d35524c TS |
167 | .SEGBITS = 32, |
168 | .PABITS = 32, | |
73642f5b | 169 | .insn_flags = CPU_MIPS32, |
6d35524c | 170 | .mmu_type = MMU_TYPE_R4000, |
34ee2ede | 171 | }, |
8d162c2b TS |
172 | { |
173 | .name = "4KEmR1", | |
174 | .CP0_PRid = 0x00018500, | |
6d35524c | 175 | .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_FMT << CP0C0_MT), |
8d162c2b | 176 | .CP0_Config1 = MIPS_CONFIG1 | |
6958549d | 177 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
d19954f4 NF |
178 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) | |
179 | (1 << CP0C1_CA), | |
8d162c2b TS |
180 | .CP0_Config2 = MIPS_CONFIG2, |
181 | .CP0_Config3 = MIPS_CONFIG3, | |
2a6e32dd AJ |
182 | .CP0_LLAddr_rw_bitmask = 0, |
183 | .CP0_LLAddr_shift = 4, | |
8d162c2b TS |
184 | .SYNCI_Step = 32, |
185 | .CCRes = 2, | |
186 | .CP0_Status_rw_bitmask = 0x1258FF17, | |
6d35524c TS |
187 | .SEGBITS = 32, |
188 | .PABITS = 32, | |
8d162c2b | 189 | .insn_flags = CPU_MIPS32 | ASE_MIPS16, |
6d35524c | 190 | .mmu_type = MMU_TYPE_FMT, |
8d162c2b | 191 | }, |
34ee2ede TS |
192 | { |
193 | .name = "4KEc", | |
194 | .CP0_PRid = 0x00019000, | |
6d35524c TS |
195 | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | |
196 | (MMU_TYPE_R4000 << CP0C0_MT), | |
ae5d8053 | 197 | .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) | |
6958549d | 198 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
d19954f4 | 199 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) | |
ab3aee26 | 200 | (0 << CP0C1_CA), |
34ee2ede | 201 | .CP0_Config2 = MIPS_CONFIG2, |
ead9360e | 202 | .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt), |
2a6e32dd AJ |
203 | .CP0_LLAddr_rw_bitmask = 0, |
204 | .CP0_LLAddr_shift = 4, | |
2f644545 TS |
205 | .SYNCI_Step = 32, |
206 | .CCRes = 2, | |
ead9360e | 207 | .CP0_Status_rw_bitmask = 0x1278FF17, |
6d35524c TS |
208 | .SEGBITS = 32, |
209 | .PABITS = 32, | |
73642f5b | 210 | .insn_flags = CPU_MIPS32R2, |
6d35524c | 211 | .mmu_type = MMU_TYPE_R4000, |
34ee2ede | 212 | }, |
3e4587d5 TS |
213 | { |
214 | .name = "4KEm", | |
215 | .CP0_PRid = 0x00019100, | |
6d35524c | 216 | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | |
6958549d | 217 | (MMU_TYPE_FMT << CP0C0_MT), |
3e4587d5 | 218 | .CP0_Config1 = MIPS_CONFIG1 | |
6958549d | 219 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
d19954f4 NF |
220 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) | |
221 | (1 << CP0C1_CA), | |
3e4587d5 TS |
222 | .CP0_Config2 = MIPS_CONFIG2, |
223 | .CP0_Config3 = MIPS_CONFIG3, | |
2a6e32dd AJ |
224 | .CP0_LLAddr_rw_bitmask = 0, |
225 | .CP0_LLAddr_shift = 4, | |
3e4587d5 TS |
226 | .SYNCI_Step = 32, |
227 | .CCRes = 2, | |
228 | .CP0_Status_rw_bitmask = 0x1258FF17, | |
6d35524c TS |
229 | .SEGBITS = 32, |
230 | .PABITS = 32, | |
3e4587d5 | 231 | .insn_flags = CPU_MIPS32R2 | ASE_MIPS16, |
6d35524c | 232 | .mmu_type = MMU_TYPE_FMT, |
3e4587d5 | 233 | }, |
34ee2ede TS |
234 | { |
235 | .name = "24Kc", | |
236 | .CP0_PRid = 0x00019300, | |
6d35524c | 237 | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | |
6958549d | 238 | (MMU_TYPE_R4000 << CP0C0_MT), |
ae5d8053 | 239 | .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) | |
6958549d | 240 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
d19954f4 NF |
241 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) | |
242 | (1 << CP0C1_CA), | |
3953d786 | 243 | .CP0_Config2 = MIPS_CONFIG2, |
ead9360e | 244 | .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt), |
2a6e32dd AJ |
245 | .CP0_LLAddr_rw_bitmask = 0, |
246 | .CP0_LLAddr_shift = 4, | |
2f644545 TS |
247 | .SYNCI_Step = 32, |
248 | .CCRes = 2, | |
ead9360e | 249 | /* No DSP implemented. */ |
671880e6 | 250 | .CP0_Status_rw_bitmask = 0x1278FF1F, |
6d35524c TS |
251 | .SEGBITS = 32, |
252 | .PABITS = 32, | |
3e4587d5 | 253 | .insn_flags = CPU_MIPS32R2 | ASE_MIPS16, |
6d35524c | 254 | .mmu_type = MMU_TYPE_R4000, |
33d68b5f TS |
255 | }, |
256 | { | |
257 | .name = "24Kf", | |
258 | .CP0_PRid = 0x00019300, | |
6d35524c TS |
259 | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | |
260 | (MMU_TYPE_R4000 << CP0C0_MT), | |
ae5d8053 | 261 | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) | |
6958549d | 262 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
d19954f4 NF |
263 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) | |
264 | (1 << CP0C1_CA), | |
3953d786 | 265 | .CP0_Config2 = MIPS_CONFIG2, |
ead9360e | 266 | .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt), |
2a6e32dd AJ |
267 | .CP0_LLAddr_rw_bitmask = 0, |
268 | .CP0_LLAddr_shift = 4, | |
2f644545 TS |
269 | .SYNCI_Step = 32, |
270 | .CCRes = 2, | |
ead9360e | 271 | /* No DSP implemented. */ |
671880e6 | 272 | .CP0_Status_rw_bitmask = 0x3678FF1F, |
5a5012ec TS |
273 | .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) | |
274 | (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID), | |
6d35524c TS |
275 | .SEGBITS = 32, |
276 | .PABITS = 32, | |
3e4587d5 | 277 | .insn_flags = CPU_MIPS32R2 | ASE_MIPS16, |
6d35524c | 278 | .mmu_type = MMU_TYPE_R4000, |
33d68b5f | 279 | }, |
ead9360e TS |
280 | { |
281 | .name = "34Kf", | |
282 | .CP0_PRid = 0x00019500, | |
6d35524c | 283 | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | |
6958549d | 284 | (MMU_TYPE_R4000 << CP0C0_MT), |
ead9360e | 285 | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) | |
6958549d | 286 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
d19954f4 NF |
287 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) | |
288 | (1 << CP0C1_CA), | |
ead9360e | 289 | .CP0_Config2 = MIPS_CONFIG2, |
b9ac5d92 YK |
290 | .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_VInt) | (1 << CP0C3_MT) | |
291 | (1 << CP0C3_DSPP), | |
2a6e32dd AJ |
292 | .CP0_LLAddr_rw_bitmask = 0, |
293 | .CP0_LLAddr_shift = 0, | |
ead9360e TS |
294 | .SYNCI_Step = 32, |
295 | .CCRes = 2, | |
b9ac5d92 | 296 | .CP0_Status_rw_bitmask = 0x3778FF1F, |
ead9360e TS |
297 | .CP0_TCStatus_rw_bitmask = (0 << CP0TCSt_TCU3) | (0 << CP0TCSt_TCU2) | |
298 | (1 << CP0TCSt_TCU1) | (1 << CP0TCSt_TCU0) | | |
299 | (0 << CP0TCSt_TMX) | (1 << CP0TCSt_DT) | | |
300 | (1 << CP0TCSt_DA) | (1 << CP0TCSt_A) | | |
301 | (0x3 << CP0TCSt_TKSU) | (1 << CP0TCSt_IXMT) | | |
302 | (0xff << CP0TCSt_TASID), | |
303 | .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) | | |
304 | (1 << FCR0_D) | (1 << FCR0_S) | (0x95 << FCR0_PRID), | |
305 | .CP0_SRSCtl = (0xf << CP0SRSCtl_HSS), | |
306 | .CP0_SRSConf0_rw_bitmask = 0x3fffffff, | |
f45cb2f4 | 307 | .CP0_SRSConf0 = (1U << CP0SRSC0_M) | (0x3fe << CP0SRSC0_SRS3) | |
ead9360e TS |
308 | (0x3fe << CP0SRSC0_SRS2) | (0x3fe << CP0SRSC0_SRS1), |
309 | .CP0_SRSConf1_rw_bitmask = 0x3fffffff, | |
f45cb2f4 | 310 | .CP0_SRSConf1 = (1U << CP0SRSC1_M) | (0x3fe << CP0SRSC1_SRS6) | |
ead9360e TS |
311 | (0x3fe << CP0SRSC1_SRS5) | (0x3fe << CP0SRSC1_SRS4), |
312 | .CP0_SRSConf2_rw_bitmask = 0x3fffffff, | |
f45cb2f4 | 313 | .CP0_SRSConf2 = (1U << CP0SRSC2_M) | (0x3fe << CP0SRSC2_SRS9) | |
ead9360e TS |
314 | (0x3fe << CP0SRSC2_SRS8) | (0x3fe << CP0SRSC2_SRS7), |
315 | .CP0_SRSConf3_rw_bitmask = 0x3fffffff, | |
f45cb2f4 | 316 | .CP0_SRSConf3 = (1U << CP0SRSC3_M) | (0x3fe << CP0SRSC3_SRS12) | |
ead9360e TS |
317 | (0x3fe << CP0SRSC3_SRS11) | (0x3fe << CP0SRSC3_SRS10), |
318 | .CP0_SRSConf4_rw_bitmask = 0x3fffffff, | |
319 | .CP0_SRSConf4 = (0x3fe << CP0SRSC4_SRS15) | | |
320 | (0x3fe << CP0SRSC4_SRS14) | (0x3fe << CP0SRSC4_SRS13), | |
6d35524c TS |
321 | .SEGBITS = 32, |
322 | .PABITS = 32, | |
7385ac0b | 323 | .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_MT, |
6d35524c | 324 | .mmu_type = MMU_TYPE_R4000, |
ead9360e | 325 | }, |
af13ae03 JL |
326 | { |
327 | .name = "74Kf", | |
328 | .CP0_PRid = 0x00019700, | |
329 | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | | |
330 | (MMU_TYPE_R4000 << CP0C0_MT), | |
331 | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) | | |
332 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | | |
333 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA) | | |
334 | (1 << CP0C1_CA), | |
335 | .CP0_Config2 = MIPS_CONFIG2, | |
e30614d5 | 336 | .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_DSP2P) | (1 << CP0C3_DSPP) | |
4386f087 | 337 | (1 << CP0C3_VInt), |
af13ae03 JL |
338 | .CP0_LLAddr_rw_bitmask = 0, |
339 | .CP0_LLAddr_shift = 4, | |
340 | .SYNCI_Step = 32, | |
341 | .CCRes = 2, | |
342 | .CP0_Status_rw_bitmask = 0x3778FF1F, | |
343 | .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) | | |
344 | (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID), | |
345 | .SEGBITS = 32, | |
346 | .PABITS = 32, | |
347 | .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_DSPR2, | |
348 | .mmu_type = MMU_TYPE_R4000, | |
349 | }, | |
11f5ea10 MR |
350 | { |
351 | .name = "M14K", | |
352 | .CP0_PRid = 0x00019b00, | |
353 | /* Config1 implemented, fixed mapping MMU, | |
354 | no virtual icache, uncached coherency. */ | |
355 | .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_KU) | (0x2 << CP0C0_K23) | | |
356 | (0x1 << CP0C0_AR) | (MMU_TYPE_FMT << CP0C0_MT), | |
357 | .CP0_Config1 = MIPS_CONFIG1, | |
358 | .CP0_Config2 = MIPS_CONFIG2, | |
359 | .CP0_Config3 = MIPS_CONFIG3 | (0x2 << CP0C3_ISA) | (1 << CP0C3_VInt), | |
360 | .CP0_LLAddr_rw_bitmask = 0, | |
361 | .CP0_LLAddr_shift = 4, | |
362 | .SYNCI_Step = 32, | |
363 | .CCRes = 2, | |
364 | .CP0_Status_rw_bitmask = 0x1258FF17, | |
365 | .SEGBITS = 32, | |
366 | .PABITS = 32, | |
367 | .insn_flags = CPU_MIPS32R2 | ASE_MICROMIPS, | |
368 | .mmu_type = MMU_TYPE_FMT, | |
369 | }, | |
370 | { | |
371 | .name = "M14Kc", | |
372 | /* This is the TLB-based MMU core. */ | |
373 | .CP0_PRid = 0x00019c00, | |
374 | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | | |
375 | (MMU_TYPE_R4000 << CP0C0_MT), | |
376 | .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) | | |
377 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | | |
378 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), | |
379 | .CP0_Config2 = MIPS_CONFIG2, | |
380 | .CP0_Config3 = MIPS_CONFIG3 | (0x2 << CP0C3_ISA) | (0 << CP0C3_VInt), | |
381 | .CP0_LLAddr_rw_bitmask = 0, | |
382 | .CP0_LLAddr_shift = 4, | |
383 | .SYNCI_Step = 32, | |
384 | .CCRes = 2, | |
385 | .CP0_Status_rw_bitmask = 0x1278FF17, | |
386 | .SEGBITS = 32, | |
387 | .PABITS = 32, | |
388 | .insn_flags = CPU_MIPS32R2 | ASE_MICROMIPS, | |
389 | .mmu_type = MMU_TYPE_R4000, | |
390 | }, | |
e527526d | 391 | { |
aff2bc6d YK |
392 | /* FIXME: |
393 | * Config3: CMGCR, SC, PW, VZ, CTXTC, CDMM, TL | |
394 | * Config4: MMUExtDef | |
395 | * Config5: EVA, MRP | |
396 | * FIR(FCR0): Has2008 | |
397 | * */ | |
398 | .name = "P5600", | |
399 | .CP0_PRid = 0x0001A800, | |
400 | .CP0_Config0 = MIPS_CONFIG0 | (1 << CP0C0_MM) | (1 << CP0C0_AR) | | |
e527526d | 401 | (MMU_TYPE_R4000 << CP0C0_MT), |
aff2bc6d YK |
402 | .CP0_Config1 = MIPS_CONFIG1 | (0x3F << CP0C1_MMU) | |
403 | (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) | | |
404 | (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) | | |
405 | (1 << CP0C1_PC) | (1 << CP0C1_FP), | |
e527526d | 406 | .CP0_Config2 = MIPS_CONFIG2, |
6773f9b6 | 407 | .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) | (1 << CP0C3_MSAP) | |
aff2bc6d YK |
408 | (1 << CP0C3_BP) | (1 << CP0C3_BI) | (1 << CP0C3_ULRI) | |
409 | (1 << CP0C3_RXI) | (1 << CP0C3_LPA) | (1 << CP0C3_VInt), | |
410 | .CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | (2 << CP0C4_IE) | | |
411 | (0x1c << CP0C4_KScrExist), | |
b4160af1 | 412 | .CP0_Config4_rw_bitmask = 0, |
aff2bc6d YK |
413 | .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_MVH) | (1 << CP0C5_LLB), |
414 | .CP0_Config5_rw_bitmask = (1 << CP0C5_K) | (1 << CP0C5_CV) | | |
415 | (1 << CP0C5_MSAEn) | (1 << CP0C5_UFE) | | |
416 | (1 << CP0C5_FRE) | (1 << CP0C5_UFR), | |
e527526d | 417 | .CP0_LLAddr_rw_bitmask = 0, |
aff2bc6d | 418 | .CP0_LLAddr_shift = 0, |
e527526d PJ |
419 | .SYNCI_Step = 32, |
420 | .CCRes = 2, | |
aff2bc6d YK |
421 | .CP0_Status_rw_bitmask = 0x3C68FF1F, |
422 | .CP0_PageGrain_rw_bitmask = (1U << CP0PG_RIE) | (1 << CP0PG_XIE) | | |
423 | (1 << CP0PG_ELPA) | (1 << CP0PG_IEC), | |
424 | .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_UFRP) | (1 << FCR0_F64) | | |
425 | (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) | | |
426 | (1 << FCR0_S) | (0x03 << FCR0_PRID), | |
e527526d | 427 | .SEGBITS = 32, |
6773f9b6 | 428 | .PABITS = 40, |
aff2bc6d | 429 | .insn_flags = CPU_MIPS32R5 | ASE_MSA, |
e527526d PJ |
430 | .mmu_type = MMU_TYPE_R4000, |
431 | }, | |
4b3bcd01 YK |
432 | { |
433 | /* A generic CPU supporting MIPS32 Release 6 ISA. | |
434 | FIXME: Support IEEE 754-2008 FP. | |
435 | Eventually this should be replaced by a real CPU model. */ | |
436 | .name = "mips32r6-generic", | |
437 | .CP0_PRid = 0x00010000, | |
438 | .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AR) | | |
439 | (MMU_TYPE_R4000 << CP0C0_MT), | |
440 | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (31 << CP0C1_MMU) | | |
441 | (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) | | |
442 | (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) | | |
443 | (0 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), | |
444 | .CP0_Config2 = MIPS_CONFIG2, | |
445 | .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_BP) | (1 << CP0C3_BI) | | |
446 | (2 << CP0C3_ISA) | (1 << CP0C3_ULRI) | | |
447 | (1 << CP0C3_RXI) | (1U << CP0C3_M), | |
448 | .CP0_Config4 = MIPS_CONFIG4 | (0xfc << CP0C4_KScrExist) | | |
449 | (3 << CP0C4_IE) | (1U << CP0C4_M), | |
450 | .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_LLB), | |
451 | .CP0_Config5_rw_bitmask = (1 << CP0C5_SBRI) | (1 << CP0C5_FRE) | | |
452 | (1 << CP0C5_UFE), | |
453 | .CP0_LLAddr_rw_bitmask = 0, | |
454 | .CP0_LLAddr_shift = 0, | |
455 | .SYNCI_Step = 32, | |
456 | .CCRes = 2, | |
457 | .CP0_Status_rw_bitmask = 0x3058FF1F, | |
458 | .CP0_PageGrain = (1 << CP0PG_IEC) | (1 << CP0PG_XIE) | | |
459 | (1U << CP0PG_RIE), | |
460 | .CP0_PageGrain_rw_bitmask = 0, | |
461 | .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_F64) | (1 << FCR0_L) | | |
462 | (1 << FCR0_W) | (1 << FCR0_D) | (1 << FCR0_S) | | |
463 | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV), | |
464 | .SEGBITS = 32, | |
465 | .PABITS = 32, | |
466 | .insn_flags = CPU_MIPS32R6 | ASE_MICROMIPS, | |
467 | .mmu_type = MMU_TYPE_R4000, | |
468 | }, | |
d26bc211 | 469 | #if defined(TARGET_MIPS64) |
33d68b5f TS |
470 | { |
471 | .name = "R4000", | |
472 | .CP0_PRid = 0x00000400, | |
6d35524c TS |
473 | /* No L2 cache, icache size 8k, dcache size 8k, uncached coherency. */ |
474 | .CP0_Config0 = (1 << 17) | (0x1 << 9) | (0x1 << 6) | (0x2 << CP0C0_K0), | |
6958549d | 475 | /* Note: Config1 is only used internally, the R4000 has only Config0. */ |
6d35524c | 476 | .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU), |
2a6e32dd AJ |
477 | .CP0_LLAddr_rw_bitmask = 0xFFFFFFFF, |
478 | .CP0_LLAddr_shift = 4, | |
2f644545 TS |
479 | .SYNCI_Step = 16, |
480 | .CCRes = 2, | |
ead9360e | 481 | .CP0_Status_rw_bitmask = 0x3678FFFF, |
6958549d | 482 | /* The R4000 has a full 64bit FPU but doesn't use the fcr0 bits. */ |
c9c1a064 | 483 | .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x0 << FCR0_REV), |
e034e2c3 | 484 | .SEGBITS = 40, |
6d35524c | 485 | .PABITS = 36, |
e189e748 | 486 | .insn_flags = CPU_MIPS3, |
6d35524c | 487 | .mmu_type = MMU_TYPE_R4000, |
c9c1a064 | 488 | }, |
e9c71dd1 TS |
489 | { |
490 | .name = "VR5432", | |
491 | .CP0_PRid = 0x00005400, | |
492 | /* No L2 cache, icache size 8k, dcache size 8k, uncached coherency. */ | |
493 | .CP0_Config0 = (1 << 17) | (0x1 << 9) | (0x1 << 6) | (0x2 << CP0C0_K0), | |
494 | .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU), | |
2a6e32dd AJ |
495 | .CP0_LLAddr_rw_bitmask = 0xFFFFFFFFL, |
496 | .CP0_LLAddr_shift = 4, | |
e9c71dd1 TS |
497 | .SYNCI_Step = 16, |
498 | .CCRes = 2, | |
499 | .CP0_Status_rw_bitmask = 0x3678FFFF, | |
500 | /* The VR5432 has a full 64bit FPU but doesn't use the fcr0 bits. */ | |
501 | .CP1_fcr0 = (0x54 << FCR0_PRID) | (0x0 << FCR0_REV), | |
502 | .SEGBITS = 40, | |
503 | .PABITS = 32, | |
504 | .insn_flags = CPU_VR54XX, | |
505 | .mmu_type = MMU_TYPE_R4000, | |
506 | }, | |
c9c1a064 TS |
507 | { |
508 | .name = "5Kc", | |
509 | .CP0_PRid = 0x00018100, | |
29fe0e34 | 510 | .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) | |
6958549d | 511 | (MMU_TYPE_R4000 << CP0C0_MT), |
c9c1a064 | 512 | .CP0_Config1 = MIPS_CONFIG1 | (31 << CP0C1_MMU) | |
6958549d AJ |
513 | (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) | |
514 | (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) | | |
515 | (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), | |
c9c1a064 TS |
516 | .CP0_Config2 = MIPS_CONFIG2, |
517 | .CP0_Config3 = MIPS_CONFIG3, | |
2a6e32dd AJ |
518 | .CP0_LLAddr_rw_bitmask = 0, |
519 | .CP0_LLAddr_shift = 4, | |
c9c1a064 TS |
520 | .SYNCI_Step = 32, |
521 | .CCRes = 2, | |
196a7958 | 522 | .CP0_Status_rw_bitmask = 0x12F8FFFF, |
e034e2c3 | 523 | .SEGBITS = 42, |
6d35524c | 524 | .PABITS = 36, |
e189e748 | 525 | .insn_flags = CPU_MIPS64, |
6d35524c | 526 | .mmu_type = MMU_TYPE_R4000, |
c9c1a064 TS |
527 | }, |
528 | { | |
529 | .name = "5Kf", | |
530 | .CP0_PRid = 0x00018100, | |
29fe0e34 | 531 | .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) | |
6958549d | 532 | (MMU_TYPE_R4000 << CP0C0_MT), |
c9c1a064 | 533 | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (31 << CP0C1_MMU) | |
6958549d AJ |
534 | (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) | |
535 | (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) | | |
536 | (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), | |
c9c1a064 TS |
537 | .CP0_Config2 = MIPS_CONFIG2, |
538 | .CP0_Config3 = MIPS_CONFIG3, | |
2a6e32dd AJ |
539 | .CP0_LLAddr_rw_bitmask = 0, |
540 | .CP0_LLAddr_shift = 4, | |
c9c1a064 TS |
541 | .SYNCI_Step = 32, |
542 | .CCRes = 2, | |
ead9360e | 543 | .CP0_Status_rw_bitmask = 0x36F8FFFF, |
6958549d | 544 | /* The 5Kf has F64 / L / W but doesn't use the fcr0 bits. */ |
c9c1a064 TS |
545 | .CP1_fcr0 = (1 << FCR0_D) | (1 << FCR0_S) | |
546 | (0x81 << FCR0_PRID) | (0x0 << FCR0_REV), | |
e034e2c3 | 547 | .SEGBITS = 42, |
6d35524c | 548 | .PABITS = 36, |
e189e748 | 549 | .insn_flags = CPU_MIPS64, |
6d35524c | 550 | .mmu_type = MMU_TYPE_R4000, |
c9c1a064 TS |
551 | }, |
552 | { | |
553 | .name = "20Kc", | |
6958549d | 554 | /* We emulate a later version of the 20Kc, earlier ones had a broken |
bd04c6fe TS |
555 | WAIT instruction. */ |
556 | .CP0_PRid = 0x000182a0, | |
29fe0e34 | 557 | .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) | |
6d35524c | 558 | (MMU_TYPE_R4000 << CP0C0_MT) | (1 << CP0C0_VI), |
c9c1a064 | 559 | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (47 << CP0C1_MMU) | |
6958549d AJ |
560 | (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) | |
561 | (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) | | |
562 | (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), | |
c9c1a064 TS |
563 | .CP0_Config2 = MIPS_CONFIG2, |
564 | .CP0_Config3 = MIPS_CONFIG3, | |
2a6e32dd AJ |
565 | .CP0_LLAddr_rw_bitmask = 0, |
566 | .CP0_LLAddr_shift = 0, | |
c9c1a064 | 567 | .SYNCI_Step = 32, |
a1daafd8 | 568 | .CCRes = 1, |
ead9360e | 569 | .CP0_Status_rw_bitmask = 0x36FBFFFF, |
6958549d | 570 | /* The 20Kc has F64 / L / W but doesn't use the fcr0 bits. */ |
c9c1a064 | 571 | .CP1_fcr0 = (1 << FCR0_3D) | (1 << FCR0_PS) | |
5a5012ec | 572 | (1 << FCR0_D) | (1 << FCR0_S) | |
c9c1a064 | 573 | (0x82 << FCR0_PRID) | (0x0 << FCR0_REV), |
e034e2c3 | 574 | .SEGBITS = 40, |
6d35524c | 575 | .PABITS = 36, |
e189e748 | 576 | .insn_flags = CPU_MIPS64 | ASE_MIPS3D, |
6d35524c | 577 | .mmu_type = MMU_TYPE_R4000, |
33d68b5f | 578 | }, |
d2123ead | 579 | { |
6958549d | 580 | /* A generic CPU providing MIPS64 Release 2 features. |
d2123ead TS |
581 | FIXME: Eventually this should be replaced by a real CPU model. */ |
582 | .name = "MIPS64R2-generic", | |
8c89395e | 583 | .CP0_PRid = 0x00010000, |
6d35524c | 584 | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) | |
6958549d | 585 | (MMU_TYPE_R4000 << CP0C0_MT), |
d2123ead | 586 | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) | |
6958549d AJ |
587 | (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) | |
588 | (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) | | |
589 | (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), | |
d2123ead | 590 | .CP0_Config2 = MIPS_CONFIG2, |
6d35524c | 591 | .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA), |
2a6e32dd AJ |
592 | .CP0_LLAddr_rw_bitmask = 0, |
593 | .CP0_LLAddr_shift = 0, | |
d2123ead TS |
594 | .SYNCI_Step = 32, |
595 | .CCRes = 2, | |
596 | .CP0_Status_rw_bitmask = 0x36FBFFFF, | |
ea4b07f7 TS |
597 | .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_3D) | (1 << FCR0_PS) | |
598 | (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) | | |
599 | (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV), | |
6d35524c | 600 | .SEGBITS = 42, |
6d35524c | 601 | .PABITS = 36, |
d2123ead | 602 | .insn_flags = CPU_MIPS64R2 | ASE_MIPS3D, |
6d35524c | 603 | .mmu_type = MMU_TYPE_R4000, |
d2123ead | 604 | }, |
36b86e0d MR |
605 | { |
606 | .name = "5KEc", | |
607 | .CP0_PRid = 0x00018900, | |
608 | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) | | |
609 | (MMU_TYPE_R4000 << CP0C0_MT), | |
610 | .CP0_Config1 = MIPS_CONFIG1 | (31 << CP0C1_MMU) | | |
611 | (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) | | |
612 | (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) | | |
613 | (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), | |
614 | .CP0_Config2 = MIPS_CONFIG2, | |
615 | .CP0_Config3 = MIPS_CONFIG3, | |
616 | .CP0_LLAddr_rw_bitmask = 0, | |
617 | .CP0_LLAddr_shift = 4, | |
618 | .SYNCI_Step = 32, | |
619 | .CCRes = 2, | |
196a7958 | 620 | .CP0_Status_rw_bitmask = 0x12F8FFFF, |
36b86e0d MR |
621 | .SEGBITS = 42, |
622 | .PABITS = 36, | |
623 | .insn_flags = CPU_MIPS64R2, | |
624 | .mmu_type = MMU_TYPE_R4000, | |
625 | }, | |
626 | { | |
627 | .name = "5KEf", | |
628 | .CP0_PRid = 0x00018900, | |
629 | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) | | |
630 | (MMU_TYPE_R4000 << CP0C0_MT), | |
631 | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (31 << CP0C1_MMU) | | |
632 | (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) | | |
633 | (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) | | |
634 | (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), | |
635 | .CP0_Config2 = MIPS_CONFIG2, | |
636 | .CP0_Config3 = MIPS_CONFIG3, | |
637 | .CP0_LLAddr_rw_bitmask = 0, | |
638 | .CP0_LLAddr_shift = 4, | |
639 | .SYNCI_Step = 32, | |
640 | .CCRes = 2, | |
641 | .CP0_Status_rw_bitmask = 0x36F8FFFF, | |
642 | .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) | | |
643 | (1 << FCR0_D) | (1 << FCR0_S) | | |
644 | (0x89 << FCR0_PRID) | (0x0 << FCR0_REV), | |
645 | .SEGBITS = 42, | |
646 | .PABITS = 36, | |
647 | .insn_flags = CPU_MIPS64R2, | |
648 | .mmu_type = MMU_TYPE_R4000, | |
649 | }, | |
a773cc79 LA |
650 | { |
651 | /* A generic CPU supporting MIPS64 Release 6 ISA. | |
be3a8c53 | 652 | FIXME: Support IEEE 754-2008 FP. |
a773cc79 LA |
653 | Eventually this should be replaced by a real CPU model. */ |
654 | .name = "MIPS64R6-generic", | |
655 | .CP0_PRid = 0x00010000, | |
656 | .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AR) | (0x2 << CP0C0_AT) | | |
657 | (MMU_TYPE_R4000 << CP0C0_MT), | |
658 | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) | | |
659 | (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) | | |
660 | (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) | | |
661 | (0 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), | |
662 | .CP0_Config2 = MIPS_CONFIG2, | |
4dc89b78 YK |
663 | .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) | (1 << CP0C3_MSAP) | |
664 | (1 << CP0C3_BP) | (1 << CP0C3_BI) | (1 << CP0C3_ULRI) | | |
665 | (1 << CP0C3_RXI) | (1 << CP0C3_LPA), | |
666 | .CP0_Config4 = MIPS_CONFIG4 | (1U << CP0C4_M) | (3 << CP0C4_IE) | | |
667 | (0xfc << CP0C4_KScrExist), | |
ce9782f4 | 668 | .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_LLB), |
4dc89b78 YK |
669 | .CP0_Config5_rw_bitmask = (1 << CP0C5_MSAEn) | (1 << CP0C5_SBRI) | |
670 | (1 << CP0C5_FRE) | (1 << CP0C5_UFE), | |
a773cc79 LA |
671 | .CP0_LLAddr_rw_bitmask = 0, |
672 | .CP0_LLAddr_shift = 0, | |
673 | .SYNCI_Step = 32, | |
674 | .CCRes = 2, | |
675 | .CP0_Status_rw_bitmask = 0x30D8FFFF, | |
2d9e48bc LA |
676 | .CP0_PageGrain = (1 << CP0PG_IEC) | (1 << CP0PG_XIE) | |
677 | (1U << CP0PG_RIE), | |
6773f9b6 | 678 | .CP0_PageGrain_rw_bitmask = (1 << CP0PG_ELPA), |
7c979afd LA |
679 | .CP1_fcr0 = (1 << FCR0_FREP) | (1 << FCR0_F64) | (1 << FCR0_L) | |
680 | (1 << FCR0_W) | (1 << FCR0_D) | (1 << FCR0_S) | | |
681 | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV), | |
4dc89b78 | 682 | .SEGBITS = 48, |
6773f9b6 | 683 | .PABITS = 48, |
4dc89b78 | 684 | .insn_flags = CPU_MIPS64R6 | ASE_MSA, |
a773cc79 LA |
685 | .mmu_type = MMU_TYPE_R4000, |
686 | }, | |
5bc6fba8 HC |
687 | { |
688 | .name = "Loongson-2E", | |
689 | .CP0_PRid = 0x6302, | |
6225a4a0 MR |
690 | /* 64KB I-cache and d-cache. 4 way with 32 bit cache line size. */ |
691 | .CP0_Config0 = (0x1<<17) | (0x1<<16) | (0x1<<11) | (0x1<<8) | | |
692 | (0x1<<5) | (0x1<<4) | (0x1<<1), | |
693 | /* Note: Config1 is only used internally, | |
694 | Loongson-2E has only Config0. */ | |
5bc6fba8 HC |
695 | .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU), |
696 | .SYNCI_Step = 16, | |
697 | .CCRes = 2, | |
698 | .CP0_Status_rw_bitmask = 0x35D0FFFF, | |
699 | .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x1 << FCR0_REV), | |
700 | .SEGBITS = 40, | |
701 | .PABITS = 40, | |
702 | .insn_flags = CPU_LOONGSON2E, | |
703 | .mmu_type = MMU_TYPE_R4000, | |
704 | }, | |
705 | { | |
6225a4a0 MR |
706 | .name = "Loongson-2F", |
707 | .CP0_PRid = 0x6303, | |
708 | /* 64KB I-cache and d-cache. 4 way with 32 bit cache line size. */ | |
709 | .CP0_Config0 = (0x1<<17) | (0x1<<16) | (0x1<<11) | (0x1<<8) | | |
710 | (0x1<<5) | (0x1<<4) | (0x1<<1), | |
711 | /* Note: Config1 is only used internally, | |
712 | Loongson-2F has only Config0. */ | |
713 | .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU), | |
714 | .SYNCI_Step = 16, | |
715 | .CCRes = 2, | |
716 | .CP0_Status_rw_bitmask = 0xF5D0FF1F, /* Bits 7:5 not writable. */ | |
717 | .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x1 << FCR0_REV), | |
718 | .SEGBITS = 40, | |
719 | .PABITS = 40, | |
720 | .insn_flags = CPU_LOONGSON2F, | |
721 | .mmu_type = MMU_TYPE_R4000, | |
5bc6fba8 | 722 | }, |
af13ae03 JL |
723 | { |
724 | /* A generic CPU providing MIPS64 ASE DSP 2 features. | |
725 | FIXME: Eventually this should be replaced by a real CPU model. */ | |
726 | .name = "mips64dspr2", | |
727 | .CP0_PRid = 0x00010000, | |
728 | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) | | |
729 | (MMU_TYPE_R4000 << CP0C0_MT), | |
730 | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) | | |
731 | (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) | | |
732 | (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) | | |
733 | (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), | |
734 | .CP0_Config2 = MIPS_CONFIG2, | |
e30614d5 MR |
735 | .CP0_Config3 = MIPS_CONFIG3 | (1U << CP0C3_M) | (1 << CP0C3_DSP2P) | |
736 | (1 << CP0C3_DSPP) | (1 << CP0C3_LPA), | |
af13ae03 JL |
737 | .CP0_LLAddr_rw_bitmask = 0, |
738 | .CP0_LLAddr_shift = 0, | |
739 | .SYNCI_Step = 32, | |
740 | .CCRes = 2, | |
741 | .CP0_Status_rw_bitmask = 0x37FBFFFF, | |
742 | .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_3D) | (1 << FCR0_PS) | | |
743 | (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) | | |
744 | (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV), | |
745 | .SEGBITS = 42, | |
af13ae03 JL |
746 | .PABITS = 36, |
747 | .insn_flags = CPU_MIPS64R2 | ASE_DSP | ASE_DSPR2, | |
748 | .mmu_type = MMU_TYPE_R4000, | |
749 | }, | |
5bc6fba8 | 750 | |
33d68b5f TS |
751 | #endif |
752 | }; | |
753 | ||
c227f099 | 754 | static const mips_def_t *cpu_mips_find_by_name (const char *name) |
33d68b5f | 755 | { |
aaed909a | 756 | int i; |
33d68b5f | 757 | |
b1503cda | 758 | for (i = 0; i < ARRAY_SIZE(mips_defs); i++) { |
33d68b5f | 759 | if (strcasecmp(name, mips_defs[i].name) == 0) { |
aaed909a | 760 | return &mips_defs[i]; |
33d68b5f TS |
761 | } |
762 | } | |
aaed909a | 763 | return NULL; |
33d68b5f TS |
764 | } |
765 | ||
9a78eead | 766 | void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf) |
33d68b5f TS |
767 | { |
768 | int i; | |
769 | ||
b1503cda | 770 | for (i = 0; i < ARRAY_SIZE(mips_defs); i++) { |
33d68b5f TS |
771 | (*cpu_fprintf)(f, "MIPS '%s'\n", |
772 | mips_defs[i].name); | |
773 | } | |
774 | } | |
775 | ||
f8a6ec58 | 776 | #ifndef CONFIG_USER_ONLY |
c227f099 | 777 | static void no_mmu_init (CPUMIPSState *env, const mips_def_t *def) |
29929e34 | 778 | { |
ead9360e TS |
779 | env->tlb->nb_tlb = 1; |
780 | env->tlb->map_address = &no_mmu_map_address; | |
29929e34 TS |
781 | } |
782 | ||
c227f099 | 783 | static void fixed_mmu_init (CPUMIPSState *env, const mips_def_t *def) |
29929e34 | 784 | { |
ead9360e TS |
785 | env->tlb->nb_tlb = 1; |
786 | env->tlb->map_address = &fixed_mmu_map_address; | |
29929e34 TS |
787 | } |
788 | ||
c227f099 | 789 | static void r4k_mmu_init (CPUMIPSState *env, const mips_def_t *def) |
29929e34 | 790 | { |
ead9360e TS |
791 | env->tlb->nb_tlb = 1 + ((def->CP0_Config1 >> CP0C1_MMU) & 63); |
792 | env->tlb->map_address = &r4k_map_address; | |
c01fccd2 AJ |
793 | env->tlb->helper_tlbwi = r4k_helper_tlbwi; |
794 | env->tlb->helper_tlbwr = r4k_helper_tlbwr; | |
795 | env->tlb->helper_tlbp = r4k_helper_tlbp; | |
796 | env->tlb->helper_tlbr = r4k_helper_tlbr; | |
9456c2fb LA |
797 | env->tlb->helper_tlbinv = r4k_helper_tlbinv; |
798 | env->tlb->helper_tlbinvf = r4k_helper_tlbinvf; | |
ead9360e TS |
799 | } |
800 | ||
c227f099 | 801 | static void mmu_init (CPUMIPSState *env, const mips_def_t *def) |
ead9360e | 802 | { |
a47dddd7 AF |
803 | MIPSCPU *cpu = mips_env_get_cpu(env); |
804 | ||
7267c094 | 805 | env->tlb = g_malloc0(sizeof(CPUMIPSTLBContext)); |
ead9360e | 806 | |
6d35524c TS |
807 | switch (def->mmu_type) { |
808 | case MMU_TYPE_NONE: | |
ead9360e TS |
809 | no_mmu_init(env, def); |
810 | break; | |
6d35524c | 811 | case MMU_TYPE_R4000: |
ead9360e TS |
812 | r4k_mmu_init(env, def); |
813 | break; | |
6d35524c | 814 | case MMU_TYPE_FMT: |
ead9360e TS |
815 | fixed_mmu_init(env, def); |
816 | break; | |
6d35524c TS |
817 | case MMU_TYPE_R3000: |
818 | case MMU_TYPE_R6000: | |
819 | case MMU_TYPE_R8000: | |
ead9360e | 820 | default: |
a47dddd7 | 821 | cpu_abort(CPU(cpu), "MMU type not supported\n"); |
ead9360e | 822 | } |
29929e34 | 823 | } |
f8a6ec58 | 824 | #endif /* CONFIG_USER_ONLY */ |
29929e34 | 825 | |
c227f099 | 826 | static void fpu_init (CPUMIPSState *env, const mips_def_t *def) |
ead9360e | 827 | { |
f01be154 TS |
828 | int i; |
829 | ||
830 | for (i = 0; i < MIPS_FPU_MAX; i++) | |
831 | env->fpus[i].fcr0 = def->CP1_fcr0; | |
ead9360e | 832 | |
f01be154 | 833 | memcpy(&env->active_fpu, &env->fpus[0], sizeof(env->active_fpu)); |
ead9360e TS |
834 | } |
835 | ||
c227f099 | 836 | static void mvp_init (CPUMIPSState *env, const mips_def_t *def) |
ead9360e | 837 | { |
7267c094 | 838 | env->mvp = g_malloc0(sizeof(CPUMIPSMVPContext)); |
ead9360e TS |
839 | |
840 | /* MVPConf1 implemented, TLB sharable, no gating storage support, | |
841 | programmable cache partitioning implemented, number of allocatable | |
842 | and sharable TLB entries, MVP has allocatable TCs, 2 VPEs | |
843 | implemented, 5 TCs implemented. */ | |
f45cb2f4 | 844 | env->mvp->CP0_MVPConf0 = (1U << CP0MVPC0_M) | (1 << CP0MVPC0_TLBS) | |
ead9360e | 845 | (0 << CP0MVPC0_GS) | (1 << CP0MVPC0_PCP) | |
ead9360e TS |
846 | // TODO: actually do 2 VPEs. |
847 | // (1 << CP0MVPC0_TCA) | (0x1 << CP0MVPC0_PVPE) | | |
848 | // (0x04 << CP0MVPC0_PTC); | |
849 | (1 << CP0MVPC0_TCA) | (0x0 << CP0MVPC0_PVPE) | | |
1dab005a | 850 | (0x00 << CP0MVPC0_PTC); |
932e71cd | 851 | #if !defined(CONFIG_USER_ONLY) |
0eaef5aa | 852 | /* Usermode has no TLB support */ |
932e71cd AJ |
853 | env->mvp->CP0_MVPConf0 |= (env->tlb->nb_tlb << CP0MVPC0_PTLBE); |
854 | #endif | |
0eaef5aa | 855 | |
ead9360e TS |
856 | /* Allocatable CP1 have media extensions, allocatable CP1 have FP support, |
857 | no UDI implemented, no CP2 implemented, 1 CP1 implemented. */ | |
f45cb2f4 | 858 | env->mvp->CP0_MVPConf1 = (1U << CP0MVPC1_CIM) | (1 << CP0MVPC1_CIF) | |
ead9360e TS |
859 | (0x0 << CP0MVPC1_PCX) | (0x0 << CP0MVPC1_PCP2) | |
860 | (0x1 << CP0MVPC1_PCP1); | |
861 | } | |
863f264d YK |
862 | |
863 | static void msa_reset(CPUMIPSState *env) | |
864 | { | |
865 | #ifdef CONFIG_USER_ONLY | |
866 | /* MSA access enabled */ | |
867 | env->CP0_Config5 |= 1 << CP0C5_MSAEn; | |
868 | env->CP0_Status |= (1 << CP0St_CU1) | (1 << CP0St_FR); | |
869 | #endif | |
870 | ||
871 | /* MSA CSR: | |
872 | - non-signaling floating point exception mode off (NX bit is 0) | |
873 | - Cause, Enables, and Flags are all 0 | |
874 | - round to nearest / ties to even (RM bits are 0) */ | |
875 | env->active_tc.msacsr = 0; | |
876 | ||
64451111 LA |
877 | restore_msa_fp_status(env); |
878 | ||
863f264d YK |
879 | /* tininess detected after rounding.*/ |
880 | set_float_detect_tininess(float_tininess_after_rounding, | |
881 | &env->active_tc.msa_fp_status); | |
882 | ||
883 | /* clear float_status exception flags */ | |
884 | set_float_exception_flags(0, &env->active_tc.msa_fp_status); | |
885 | ||
863f264d YK |
886 | /* clear float_status nan mode */ |
887 | set_default_nan_mode(0, &env->active_tc.msa_fp_status); | |
888 | } |