root / target-mips / translate_init.c @ 51cc2e78
History | View | Annotate | Download (20 kB)
1 | 33d68b5f | ths | /*
|
---|---|---|---|
2 | 33d68b5f | ths | * MIPS emulation for qemu: CPU initialisation routines.
|
3 | 33d68b5f | ths | *
|
4 | 33d68b5f | ths | * Copyright (c) 2004-2005 Jocelyn Mayer
|
5 | 33d68b5f | ths | * Copyright (c) 2007 Herve Poussineau
|
6 | 33d68b5f | ths | *
|
7 | 33d68b5f | ths | * This library is free software; you can redistribute it and/or
|
8 | 33d68b5f | ths | * modify it under the terms of the GNU Lesser General Public
|
9 | 33d68b5f | ths | * License as published by the Free Software Foundation; either
|
10 | 33d68b5f | ths | * version 2 of the License, or (at your option) any later version.
|
11 | 33d68b5f | ths | *
|
12 | 33d68b5f | ths | * This library is distributed in the hope that it will be useful,
|
13 | 33d68b5f | ths | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 | 33d68b5f | ths | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15 | 33d68b5f | ths | * Lesser General Public License for more details.
|
16 | 33d68b5f | ths | *
|
17 | 33d68b5f | ths | * You should have received a copy of the GNU Lesser General Public
|
18 | 8167ee88 | Blue Swirl | * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
19 | 33d68b5f | ths | */
|
20 | 33d68b5f | ths | |
21 | 3953d786 | ths | /* CPU / CPU family specific config register values. */
|
22 | 3953d786 | ths | |
23 | 6d35524c | ths | /* Have config1, uncached coherency */
|
24 | 3953d786 | ths | #define MIPS_CONFIG0 \
|
25 | 6d35524c | ths | ((1 << CP0C0_M) | (0x2 << CP0C0_K0)) |
26 | 3953d786 | ths | |
27 | ae5d8053 | ths | /* Have config2, no coprocessor2 attached, no MDMX support attached,
|
28 | 3953d786 | ths | no performance counters, watch registers present,
|
29 | 3953d786 | ths | no code compression, EJTAG present, no FPU */
|
30 | 3953d786 | ths | #define MIPS_CONFIG1 \
|
31 | fcb4a419 | ths | ((1 << CP0C1_M) | \
|
32 | 3953d786 | ths | (0 << CP0C1_C2) | (0 << CP0C1_MD) | (0 << CP0C1_PC) | \ |
33 | 3953d786 | ths | (1 << CP0C1_WR) | (0 << CP0C1_CA) | (1 << CP0C1_EP) | \ |
34 | 3953d786 | ths | (0 << CP0C1_FP))
|
35 | 3953d786 | ths | |
36 | 3953d786 | ths | /* Have config3, no tertiary/secondary caches implemented */
|
37 | 3953d786 | ths | #define MIPS_CONFIG2 \
|
38 | 3953d786 | ths | ((1 << CP0C2_M))
|
39 | 3953d786 | ths | |
40 | 6d35524c | ths | /* No config4, no DSP ASE, no large physaddr (PABITS),
|
41 | 3953d786 | ths | no external interrupt controller, no vectored interupts,
|
42 | ead9360e | ths | no 1kb pages, no SmartMIPS ASE, no trace logic */
|
43 | 3953d786 | ths | #define MIPS_CONFIG3 \
|
44 | 3953d786 | ths | ((0 << CP0C3_M) | (0 << CP0C3_DSPP) | (0 << CP0C3_LPA) | \ |
45 | 3953d786 | ths | (0 << CP0C3_VEIC) | (0 << CP0C3_VInt) | (0 << CP0C3_SP) | \ |
46 | ead9360e | ths | (0 << CP0C3_SM) | (0 << CP0C3_TL)) |
47 | 3953d786 | ths | |
48 | 3953d786 | ths | /* Define a implementation number of 1.
|
49 | 3953d786 | ths | Define a major version 1, minor version 0. */
|
50 | 5a5012ec | ths | #define MIPS_FCR0 ((0 << FCR0_S) | (0x1 << FCR0_PRID) | (0x10 << FCR0_REV)) |
51 | 3953d786 | ths | |
52 | 6d35524c | ths | /* MMU types, the first four entries have the same layout as the
|
53 | 6d35524c | ths | CP0C0_MT field. */
|
54 | 6d35524c | ths | enum mips_mmu_types {
|
55 | 6d35524c | ths | MMU_TYPE_NONE, |
56 | 6d35524c | ths | MMU_TYPE_R4000, |
57 | 6d35524c | ths | MMU_TYPE_RESERVED, |
58 | 6d35524c | ths | MMU_TYPE_FMT, |
59 | 6d35524c | ths | MMU_TYPE_R3000, |
60 | 6d35524c | ths | MMU_TYPE_R6000, |
61 | 6d35524c | ths | MMU_TYPE_R8000 |
62 | 6d35524c | ths | }; |
63 | 6d35524c | ths | |
64 | c227f099 | Anthony Liguori | struct mips_def_t {
|
65 | 50366fe9 | ths | const char *name; |
66 | 33d68b5f | ths | int32_t CP0_PRid; |
67 | 33d68b5f | ths | int32_t CP0_Config0; |
68 | 33d68b5f | ths | int32_t CP0_Config1; |
69 | 3953d786 | ths | int32_t CP0_Config2; |
70 | 3953d786 | ths | int32_t CP0_Config3; |
71 | 34ee2ede | ths | int32_t CP0_Config6; |
72 | 34ee2ede | ths | int32_t CP0_Config7; |
73 | 2f644545 | ths | int32_t SYNCI_Step; |
74 | 2f644545 | ths | int32_t CCRes; |
75 | ead9360e | ths | int32_t CP0_Status_rw_bitmask; |
76 | ead9360e | ths | int32_t CP0_TCStatus_rw_bitmask; |
77 | ead9360e | ths | int32_t CP0_SRSCtl; |
78 | 3953d786 | ths | int32_t CP1_fcr0; |
79 | e034e2c3 | ths | int32_t SEGBITS; |
80 | 6d35524c | ths | int32_t PABITS; |
81 | ead9360e | ths | int32_t CP0_SRSConf0_rw_bitmask; |
82 | ead9360e | ths | int32_t CP0_SRSConf0; |
83 | ead9360e | ths | int32_t CP0_SRSConf1_rw_bitmask; |
84 | ead9360e | ths | int32_t CP0_SRSConf1; |
85 | ead9360e | ths | int32_t CP0_SRSConf2_rw_bitmask; |
86 | ead9360e | ths | int32_t CP0_SRSConf2; |
87 | ead9360e | ths | int32_t CP0_SRSConf3_rw_bitmask; |
88 | ead9360e | ths | int32_t CP0_SRSConf3; |
89 | ead9360e | ths | int32_t CP0_SRSConf4_rw_bitmask; |
90 | ead9360e | ths | int32_t CP0_SRSConf4; |
91 | e189e748 | ths | int insn_flags;
|
92 | 6d35524c | ths | enum mips_mmu_types mmu_type;
|
93 | 33d68b5f | ths | }; |
94 | 33d68b5f | ths | |
95 | 33d68b5f | ths | /*****************************************************************************/
|
96 | 33d68b5f | ths | /* MIPS CPU definitions */
|
97 | c227f099 | Anthony Liguori | static const mips_def_t mips_defs[] = |
98 | 33d68b5f | ths | { |
99 | 33d68b5f | ths | { |
100 | 33d68b5f | ths | .name = "4Kc",
|
101 | 33d68b5f | ths | .CP0_PRid = 0x00018000,
|
102 | 6d35524c | ths | .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_R4000 << CP0C0_MT), |
103 | ae5d8053 | ths | .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
|
104 | 6958549d | aurel32 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
105 | 6958549d | aurel32 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
106 | 3953d786 | ths | .CP0_Config2 = MIPS_CONFIG2, |
107 | 3953d786 | ths | .CP0_Config3 = MIPS_CONFIG3, |
108 | 2f644545 | ths | .SYNCI_Step = 32,
|
109 | 2f644545 | ths | .CCRes = 2,
|
110 | ead9360e | ths | .CP0_Status_rw_bitmask = 0x1278FF17,
|
111 | 6d35524c | ths | .SEGBITS = 32,
|
112 | 6d35524c | ths | .PABITS = 32,
|
113 | e189e748 | ths | .insn_flags = CPU_MIPS32 | ASE_MIPS16, |
114 | 6d35524c | ths | .mmu_type = MMU_TYPE_R4000, |
115 | 33d68b5f | ths | }, |
116 | 33d68b5f | ths | { |
117 | 8d162c2b | ths | .name = "4Km",
|
118 | 8d162c2b | ths | .CP0_PRid = 0x00018300,
|
119 | 8d162c2b | ths | /* Config1 implemented, fixed mapping MMU,
|
120 | 8d162c2b | ths | no virtual icache, uncached coherency. */
|
121 | 6d35524c | ths | .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_FMT << CP0C0_MT), |
122 | 8d162c2b | ths | .CP0_Config1 = MIPS_CONFIG1 | |
123 | 6958549d | aurel32 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
124 | 6958549d | aurel32 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
125 | 8d162c2b | ths | .CP0_Config2 = MIPS_CONFIG2, |
126 | 8d162c2b | ths | .CP0_Config3 = MIPS_CONFIG3, |
127 | 8d162c2b | ths | .SYNCI_Step = 32,
|
128 | 8d162c2b | ths | .CCRes = 2,
|
129 | 8d162c2b | ths | .CP0_Status_rw_bitmask = 0x1258FF17,
|
130 | 6d35524c | ths | .SEGBITS = 32,
|
131 | 6d35524c | ths | .PABITS = 32,
|
132 | 8d162c2b | ths | .insn_flags = CPU_MIPS32 | ASE_MIPS16, |
133 | 6d35524c | ths | .mmu_type = MMU_TYPE_FMT, |
134 | 8d162c2b | ths | }, |
135 | 8d162c2b | ths | { |
136 | 34ee2ede | ths | .name = "4KEcR1",
|
137 | 33d68b5f | ths | .CP0_PRid = 0x00018400,
|
138 | 6d35524c | ths | .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_R4000 << CP0C0_MT), |
139 | ae5d8053 | ths | .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
|
140 | 6958549d | aurel32 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
141 | 6958549d | aurel32 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
142 | 34ee2ede | ths | .CP0_Config2 = MIPS_CONFIG2, |
143 | 34ee2ede | ths | .CP0_Config3 = MIPS_CONFIG3, |
144 | 2f644545 | ths | .SYNCI_Step = 32,
|
145 | 2f644545 | ths | .CCRes = 2,
|
146 | ead9360e | ths | .CP0_Status_rw_bitmask = 0x1278FF17,
|
147 | 6d35524c | ths | .SEGBITS = 32,
|
148 | 6d35524c | ths | .PABITS = 32,
|
149 | e189e748 | ths | .insn_flags = CPU_MIPS32 | ASE_MIPS16, |
150 | 6d35524c | ths | .mmu_type = MMU_TYPE_R4000, |
151 | 34ee2ede | ths | }, |
152 | 34ee2ede | ths | { |
153 | 8d162c2b | ths | .name = "4KEmR1",
|
154 | 8d162c2b | ths | .CP0_PRid = 0x00018500,
|
155 | 6d35524c | ths | .CP0_Config0 = MIPS_CONFIG0 | (MMU_TYPE_FMT << CP0C0_MT), |
156 | 8d162c2b | ths | .CP0_Config1 = MIPS_CONFIG1 | |
157 | 6958549d | aurel32 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
158 | 6958549d | aurel32 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
159 | 8d162c2b | ths | .CP0_Config2 = MIPS_CONFIG2, |
160 | 8d162c2b | ths | .CP0_Config3 = MIPS_CONFIG3, |
161 | 8d162c2b | ths | .SYNCI_Step = 32,
|
162 | 8d162c2b | ths | .CCRes = 2,
|
163 | 8d162c2b | ths | .CP0_Status_rw_bitmask = 0x1258FF17,
|
164 | 6d35524c | ths | .SEGBITS = 32,
|
165 | 6d35524c | ths | .PABITS = 32,
|
166 | 8d162c2b | ths | .insn_flags = CPU_MIPS32 | ASE_MIPS16, |
167 | 6d35524c | ths | .mmu_type = MMU_TYPE_FMT, |
168 | 8d162c2b | ths | }, |
169 | 8d162c2b | ths | { |
170 | 34ee2ede | ths | .name = "4KEc",
|
171 | 34ee2ede | ths | .CP0_PRid = 0x00019000,
|
172 | 6d35524c | ths | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
|
173 | 6d35524c | ths | (MMU_TYPE_R4000 << CP0C0_MT), |
174 | ae5d8053 | ths | .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
|
175 | 6958549d | aurel32 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
176 | 6958549d | aurel32 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
177 | 34ee2ede | ths | .CP0_Config2 = MIPS_CONFIG2, |
178 | ead9360e | ths | .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
|
179 | 2f644545 | ths | .SYNCI_Step = 32,
|
180 | 2f644545 | ths | .CCRes = 2,
|
181 | ead9360e | ths | .CP0_Status_rw_bitmask = 0x1278FF17,
|
182 | 6d35524c | ths | .SEGBITS = 32,
|
183 | 6d35524c | ths | .PABITS = 32,
|
184 | e189e748 | ths | .insn_flags = CPU_MIPS32R2 | ASE_MIPS16, |
185 | 6d35524c | ths | .mmu_type = MMU_TYPE_R4000, |
186 | 34ee2ede | ths | }, |
187 | 34ee2ede | ths | { |
188 | 3e4587d5 | ths | .name = "4KEm",
|
189 | 3e4587d5 | ths | .CP0_PRid = 0x00019100,
|
190 | 6d35524c | ths | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
|
191 | 6958549d | aurel32 | (MMU_TYPE_FMT << CP0C0_MT), |
192 | 3e4587d5 | ths | .CP0_Config1 = MIPS_CONFIG1 | |
193 | 6958549d | aurel32 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
194 | 6958549d | aurel32 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
195 | 3e4587d5 | ths | .CP0_Config2 = MIPS_CONFIG2, |
196 | 3e4587d5 | ths | .CP0_Config3 = MIPS_CONFIG3, |
197 | 3e4587d5 | ths | .SYNCI_Step = 32,
|
198 | 3e4587d5 | ths | .CCRes = 2,
|
199 | 3e4587d5 | ths | .CP0_Status_rw_bitmask = 0x1258FF17,
|
200 | 6d35524c | ths | .SEGBITS = 32,
|
201 | 6d35524c | ths | .PABITS = 32,
|
202 | 3e4587d5 | ths | .insn_flags = CPU_MIPS32R2 | ASE_MIPS16, |
203 | 6d35524c | ths | .mmu_type = MMU_TYPE_FMT, |
204 | 3e4587d5 | ths | }, |
205 | 3e4587d5 | ths | { |
206 | 34ee2ede | ths | .name = "24Kc",
|
207 | 34ee2ede | ths | .CP0_PRid = 0x00019300,
|
208 | 6d35524c | ths | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
|
209 | 6958549d | aurel32 | (MMU_TYPE_R4000 << CP0C0_MT), |
210 | ae5d8053 | ths | .CP0_Config1 = MIPS_CONFIG1 | (15 << CP0C1_MMU) |
|
211 | 6958549d | aurel32 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
212 | 6958549d | aurel32 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
213 | 3953d786 | ths | .CP0_Config2 = MIPS_CONFIG2, |
214 | ead9360e | ths | .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
|
215 | 2f644545 | ths | .SYNCI_Step = 32,
|
216 | 2f644545 | ths | .CCRes = 2,
|
217 | ead9360e | ths | /* No DSP implemented. */
|
218 | 671880e6 | ths | .CP0_Status_rw_bitmask = 0x1278FF1F,
|
219 | 6d35524c | ths | .SEGBITS = 32,
|
220 | 6d35524c | ths | .PABITS = 32,
|
221 | 3e4587d5 | ths | .insn_flags = CPU_MIPS32R2 | ASE_MIPS16, |
222 | 6d35524c | ths | .mmu_type = MMU_TYPE_R4000, |
223 | 33d68b5f | ths | }, |
224 | 33d68b5f | ths | { |
225 | 33d68b5f | ths | .name = "24Kf",
|
226 | 33d68b5f | ths | .CP0_PRid = 0x00019300,
|
227 | 6d35524c | ths | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
|
228 | 6d35524c | ths | (MMU_TYPE_R4000 << CP0C0_MT), |
229 | ae5d8053 | ths | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) | |
230 | 6958549d | aurel32 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
231 | 6958549d | aurel32 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
232 | 3953d786 | ths | .CP0_Config2 = MIPS_CONFIG2, |
233 | ead9360e | ths | .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt),
|
234 | 2f644545 | ths | .SYNCI_Step = 32,
|
235 | 2f644545 | ths | .CCRes = 2,
|
236 | ead9360e | ths | /* No DSP implemented. */
|
237 | 671880e6 | ths | .CP0_Status_rw_bitmask = 0x3678FF1F,
|
238 | 5a5012ec | ths | .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) | |
239 | 5a5012ec | ths | (1 << FCR0_D) | (1 << FCR0_S) | (0x93 << FCR0_PRID), |
240 | 6d35524c | ths | .SEGBITS = 32,
|
241 | 6d35524c | ths | .PABITS = 32,
|
242 | 3e4587d5 | ths | .insn_flags = CPU_MIPS32R2 | ASE_MIPS16, |
243 | 6d35524c | ths | .mmu_type = MMU_TYPE_R4000, |
244 | 33d68b5f | ths | }, |
245 | ead9360e | ths | { |
246 | ead9360e | ths | .name = "34Kf",
|
247 | ead9360e | ths | .CP0_PRid = 0x00019500,
|
248 | 6d35524c | ths | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) |
|
249 | 6958549d | aurel32 | (MMU_TYPE_R4000 << CP0C0_MT), |
250 | ead9360e | ths | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (15 << CP0C1_MMU) | |
251 | 6958549d | aurel32 | (0 << CP0C1_IS) | (3 << CP0C1_IL) | (1 << CP0C1_IA) | |
252 | 6958549d | aurel32 | (0 << CP0C1_DS) | (3 << CP0C1_DL) | (1 << CP0C1_DA), |
253 | ead9360e | ths | .CP0_Config2 = MIPS_CONFIG2, |
254 | ead9360e | ths | .CP0_Config3 = MIPS_CONFIG3 | (0 << CP0C3_VInt) | (1 << CP0C3_MT), |
255 | ead9360e | ths | .SYNCI_Step = 32,
|
256 | ead9360e | ths | .CCRes = 2,
|
257 | ead9360e | ths | /* No DSP implemented. */
|
258 | 671880e6 | ths | .CP0_Status_rw_bitmask = 0x3678FF1F,
|
259 | ead9360e | ths | /* No DSP implemented. */
|
260 | ead9360e | ths | .CP0_TCStatus_rw_bitmask = (0 << CP0TCSt_TCU3) | (0 << CP0TCSt_TCU2) | |
261 | ead9360e | ths | (1 << CP0TCSt_TCU1) | (1 << CP0TCSt_TCU0) | |
262 | ead9360e | ths | (0 << CP0TCSt_TMX) | (1 << CP0TCSt_DT) | |
263 | ead9360e | ths | (1 << CP0TCSt_DA) | (1 << CP0TCSt_A) | |
264 | ead9360e | ths | (0x3 << CP0TCSt_TKSU) | (1 << CP0TCSt_IXMT) | |
265 | ead9360e | ths | (0xff << CP0TCSt_TASID),
|
266 | ead9360e | ths | .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_L) | (1 << FCR0_W) | |
267 | ead9360e | ths | (1 << FCR0_D) | (1 << FCR0_S) | (0x95 << FCR0_PRID), |
268 | ead9360e | ths | .CP0_SRSCtl = (0xf << CP0SRSCtl_HSS),
|
269 | ead9360e | ths | .CP0_SRSConf0_rw_bitmask = 0x3fffffff,
|
270 | ead9360e | ths | .CP0_SRSConf0 = (1 << CP0SRSC0_M) | (0x3fe << CP0SRSC0_SRS3) | |
271 | ead9360e | ths | (0x3fe << CP0SRSC0_SRS2) | (0x3fe << CP0SRSC0_SRS1), |
272 | ead9360e | ths | .CP0_SRSConf1_rw_bitmask = 0x3fffffff,
|
273 | ead9360e | ths | .CP0_SRSConf1 = (1 << CP0SRSC1_M) | (0x3fe << CP0SRSC1_SRS6) | |
274 | ead9360e | ths | (0x3fe << CP0SRSC1_SRS5) | (0x3fe << CP0SRSC1_SRS4), |
275 | ead9360e | ths | .CP0_SRSConf2_rw_bitmask = 0x3fffffff,
|
276 | ead9360e | ths | .CP0_SRSConf2 = (1 << CP0SRSC2_M) | (0x3fe << CP0SRSC2_SRS9) | |
277 | ead9360e | ths | (0x3fe << CP0SRSC2_SRS8) | (0x3fe << CP0SRSC2_SRS7), |
278 | ead9360e | ths | .CP0_SRSConf3_rw_bitmask = 0x3fffffff,
|
279 | ead9360e | ths | .CP0_SRSConf3 = (1 << CP0SRSC3_M) | (0x3fe << CP0SRSC3_SRS12) | |
280 | ead9360e | ths | (0x3fe << CP0SRSC3_SRS11) | (0x3fe << CP0SRSC3_SRS10), |
281 | ead9360e | ths | .CP0_SRSConf4_rw_bitmask = 0x3fffffff,
|
282 | ead9360e | ths | .CP0_SRSConf4 = (0x3fe << CP0SRSC4_SRS15) |
|
283 | ead9360e | ths | (0x3fe << CP0SRSC4_SRS14) | (0x3fe << CP0SRSC4_SRS13), |
284 | 6d35524c | ths | .SEGBITS = 32,
|
285 | 6d35524c | ths | .PABITS = 32,
|
286 | 7385ac0b | ths | .insn_flags = CPU_MIPS32R2 | ASE_MIPS16 | ASE_DSP | ASE_MT, |
287 | 6d35524c | ths | .mmu_type = MMU_TYPE_R4000, |
288 | ead9360e | ths | }, |
289 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
290 | 33d68b5f | ths | { |
291 | 33d68b5f | ths | .name = "R4000",
|
292 | 33d68b5f | ths | .CP0_PRid = 0x00000400,
|
293 | 6d35524c | ths | /* No L2 cache, icache size 8k, dcache size 8k, uncached coherency. */
|
294 | 6d35524c | ths | .CP0_Config0 = (1 << 17) | (0x1 << 9) | (0x1 << 6) | (0x2 << CP0C0_K0), |
295 | 6958549d | aurel32 | /* Note: Config1 is only used internally, the R4000 has only Config0. */
|
296 | 6d35524c | ths | .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU), |
297 | 2f644545 | ths | .SYNCI_Step = 16,
|
298 | 2f644545 | ths | .CCRes = 2,
|
299 | ead9360e | ths | .CP0_Status_rw_bitmask = 0x3678FFFF,
|
300 | 6958549d | aurel32 | /* The R4000 has a full 64bit FPU but doesn't use the fcr0 bits. */
|
301 | c9c1a064 | ths | .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x0 << FCR0_REV), |
302 | e034e2c3 | ths | .SEGBITS = 40,
|
303 | 6d35524c | ths | .PABITS = 36,
|
304 | e189e748 | ths | .insn_flags = CPU_MIPS3, |
305 | 6d35524c | ths | .mmu_type = MMU_TYPE_R4000, |
306 | c9c1a064 | ths | }, |
307 | e9c71dd1 | ths | { |
308 | e9c71dd1 | ths | .name = "VR5432",
|
309 | e9c71dd1 | ths | .CP0_PRid = 0x00005400,
|
310 | e9c71dd1 | ths | /* No L2 cache, icache size 8k, dcache size 8k, uncached coherency. */
|
311 | e9c71dd1 | ths | .CP0_Config0 = (1 << 17) | (0x1 << 9) | (0x1 << 6) | (0x2 << CP0C0_K0), |
312 | e9c71dd1 | ths | .CP0_Config1 = (1 << CP0C1_FP) | (47 << CP0C1_MMU), |
313 | e9c71dd1 | ths | .SYNCI_Step = 16,
|
314 | e9c71dd1 | ths | .CCRes = 2,
|
315 | e9c71dd1 | ths | .CP0_Status_rw_bitmask = 0x3678FFFF,
|
316 | e9c71dd1 | ths | /* The VR5432 has a full 64bit FPU but doesn't use the fcr0 bits. */
|
317 | e9c71dd1 | ths | .CP1_fcr0 = (0x54 << FCR0_PRID) | (0x0 << FCR0_REV), |
318 | e9c71dd1 | ths | .SEGBITS = 40,
|
319 | e9c71dd1 | ths | .PABITS = 32,
|
320 | e9c71dd1 | ths | .insn_flags = CPU_VR54XX, |
321 | e9c71dd1 | ths | .mmu_type = MMU_TYPE_R4000, |
322 | e9c71dd1 | ths | }, |
323 | c9c1a064 | ths | { |
324 | c9c1a064 | ths | .name = "5Kc",
|
325 | c9c1a064 | ths | .CP0_PRid = 0x00018100,
|
326 | 29fe0e34 | ths | .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) |
|
327 | 6958549d | aurel32 | (MMU_TYPE_R4000 << CP0C0_MT), |
328 | c9c1a064 | ths | .CP0_Config1 = MIPS_CONFIG1 | (31 << CP0C1_MMU) |
|
329 | 6958549d | aurel32 | (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) | |
330 | 6958549d | aurel32 | (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) | |
331 | 6958549d | aurel32 | (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), |
332 | c9c1a064 | ths | .CP0_Config2 = MIPS_CONFIG2, |
333 | c9c1a064 | ths | .CP0_Config3 = MIPS_CONFIG3, |
334 | c9c1a064 | ths | .SYNCI_Step = 32,
|
335 | c9c1a064 | ths | .CCRes = 2,
|
336 | ead9360e | ths | .CP0_Status_rw_bitmask = 0x32F8FFFF,
|
337 | e034e2c3 | ths | .SEGBITS = 42,
|
338 | 6d35524c | ths | .PABITS = 36,
|
339 | e189e748 | ths | .insn_flags = CPU_MIPS64, |
340 | 6d35524c | ths | .mmu_type = MMU_TYPE_R4000, |
341 | c9c1a064 | ths | }, |
342 | c9c1a064 | ths | { |
343 | c9c1a064 | ths | .name = "5Kf",
|
344 | c9c1a064 | ths | .CP0_PRid = 0x00018100,
|
345 | 29fe0e34 | ths | .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) |
|
346 | 6958549d | aurel32 | (MMU_TYPE_R4000 << CP0C0_MT), |
347 | c9c1a064 | ths | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (31 << CP0C1_MMU) | |
348 | 6958549d | aurel32 | (1 << CP0C1_IS) | (4 << CP0C1_IL) | (1 << CP0C1_IA) | |
349 | 6958549d | aurel32 | (1 << CP0C1_DS) | (4 << CP0C1_DL) | (1 << CP0C1_DA) | |
350 | 6958549d | aurel32 | (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), |
351 | c9c1a064 | ths | .CP0_Config2 = MIPS_CONFIG2, |
352 | c9c1a064 | ths | .CP0_Config3 = MIPS_CONFIG3, |
353 | c9c1a064 | ths | .SYNCI_Step = 32,
|
354 | c9c1a064 | ths | .CCRes = 2,
|
355 | ead9360e | ths | .CP0_Status_rw_bitmask = 0x36F8FFFF,
|
356 | 6958549d | aurel32 | /* The 5Kf has F64 / L / W but doesn't use the fcr0 bits. */
|
357 | c9c1a064 | ths | .CP1_fcr0 = (1 << FCR0_D) | (1 << FCR0_S) | |
358 | c9c1a064 | ths | (0x81 << FCR0_PRID) | (0x0 << FCR0_REV), |
359 | e034e2c3 | ths | .SEGBITS = 42,
|
360 | 6d35524c | ths | .PABITS = 36,
|
361 | e189e748 | ths | .insn_flags = CPU_MIPS64, |
362 | 6d35524c | ths | .mmu_type = MMU_TYPE_R4000, |
363 | c9c1a064 | ths | }, |
364 | c9c1a064 | ths | { |
365 | c9c1a064 | ths | .name = "20Kc",
|
366 | 6958549d | aurel32 | /* We emulate a later version of the 20Kc, earlier ones had a broken
|
367 | bd04c6fe | ths | WAIT instruction. */
|
368 | bd04c6fe | ths | .CP0_PRid = 0x000182a0,
|
369 | 29fe0e34 | ths | .CP0_Config0 = MIPS_CONFIG0 | (0x2 << CP0C0_AT) |
|
370 | 6d35524c | ths | (MMU_TYPE_R4000 << CP0C0_MT) | (1 << CP0C0_VI),
|
371 | c9c1a064 | ths | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (47 << CP0C1_MMU) | |
372 | 6958549d | aurel32 | (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) | |
373 | 6958549d | aurel32 | (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) | |
374 | 6958549d | aurel32 | (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), |
375 | c9c1a064 | ths | .CP0_Config2 = MIPS_CONFIG2, |
376 | c9c1a064 | ths | .CP0_Config3 = MIPS_CONFIG3, |
377 | c9c1a064 | ths | .SYNCI_Step = 32,
|
378 | a1daafd8 | ths | .CCRes = 1,
|
379 | ead9360e | ths | .CP0_Status_rw_bitmask = 0x36FBFFFF,
|
380 | 6958549d | aurel32 | /* The 20Kc has F64 / L / W but doesn't use the fcr0 bits. */
|
381 | c9c1a064 | ths | .CP1_fcr0 = (1 << FCR0_3D) | (1 << FCR0_PS) | |
382 | 5a5012ec | ths | (1 << FCR0_D) | (1 << FCR0_S) | |
383 | c9c1a064 | ths | (0x82 << FCR0_PRID) | (0x0 << FCR0_REV), |
384 | e034e2c3 | ths | .SEGBITS = 40,
|
385 | 6d35524c | ths | .PABITS = 36,
|
386 | e189e748 | ths | .insn_flags = CPU_MIPS64 | ASE_MIPS3D, |
387 | 6d35524c | ths | .mmu_type = MMU_TYPE_R4000, |
388 | 33d68b5f | ths | }, |
389 | d2123ead | ths | { |
390 | 6958549d | aurel32 | /* A generic CPU providing MIPS64 Release 2 features.
|
391 | d2123ead | ths | FIXME: Eventually this should be replaced by a real CPU model. */
|
392 | d2123ead | ths | .name = "MIPS64R2-generic",
|
393 | 8c89395e | ths | .CP0_PRid = 0x00010000,
|
394 | 6d35524c | ths | .CP0_Config0 = MIPS_CONFIG0 | (0x1 << CP0C0_AR) | (0x2 << CP0C0_AT) | |
395 | 6958549d | aurel32 | (MMU_TYPE_R4000 << CP0C0_MT), |
396 | d2123ead | ths | .CP0_Config1 = MIPS_CONFIG1 | (1 << CP0C1_FP) | (63 << CP0C1_MMU) | |
397 | 6958549d | aurel32 | (2 << CP0C1_IS) | (4 << CP0C1_IL) | (3 << CP0C1_IA) | |
398 | 6958549d | aurel32 | (2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) | |
399 | 6958549d | aurel32 | (1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP), |
400 | d2123ead | ths | .CP0_Config2 = MIPS_CONFIG2, |
401 | 6d35524c | ths | .CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA),
|
402 | d2123ead | ths | .SYNCI_Step = 32,
|
403 | d2123ead | ths | .CCRes = 2,
|
404 | d2123ead | ths | .CP0_Status_rw_bitmask = 0x36FBFFFF,
|
405 | ea4b07f7 | ths | .CP1_fcr0 = (1 << FCR0_F64) | (1 << FCR0_3D) | (1 << FCR0_PS) | |
406 | ea4b07f7 | ths | (1 << FCR0_L) | (1 << FCR0_W) | (1 << FCR0_D) | |
407 | ea4b07f7 | ths | (1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV), |
408 | 6d35524c | ths | .SEGBITS = 42,
|
409 | 6d35524c | ths | /* The architectural limit is 59, but we have hardcoded 36 bit
|
410 | 6d35524c | ths | in some places...
|
411 | 6d35524c | ths | .PABITS = 59, */ /* the architectural limit */ |
412 | 6d35524c | ths | .PABITS = 36,
|
413 | d2123ead | ths | .insn_flags = CPU_MIPS64R2 | ASE_MIPS3D, |
414 | 6d35524c | ths | .mmu_type = MMU_TYPE_R4000, |
415 | d2123ead | ths | }, |
416 | 33d68b5f | ths | #endif
|
417 | 33d68b5f | ths | }; |
418 | 33d68b5f | ths | |
419 | c227f099 | Anthony Liguori | static const mips_def_t *cpu_mips_find_by_name (const char *name) |
420 | 33d68b5f | ths | { |
421 | aaed909a | bellard | int i;
|
422 | 33d68b5f | ths | |
423 | b1503cda | malc | for (i = 0; i < ARRAY_SIZE(mips_defs); i++) { |
424 | 33d68b5f | ths | if (strcasecmp(name, mips_defs[i].name) == 0) { |
425 | aaed909a | bellard | return &mips_defs[i];
|
426 | 33d68b5f | ths | } |
427 | 33d68b5f | ths | } |
428 | aaed909a | bellard | return NULL; |
429 | 33d68b5f | ths | } |
430 | 33d68b5f | ths | |
431 | 33d68b5f | ths | void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) |
432 | 33d68b5f | ths | { |
433 | 33d68b5f | ths | int i;
|
434 | 33d68b5f | ths | |
435 | b1503cda | malc | for (i = 0; i < ARRAY_SIZE(mips_defs); i++) { |
436 | 33d68b5f | ths | (*cpu_fprintf)(f, "MIPS '%s'\n",
|
437 | 33d68b5f | ths | mips_defs[i].name); |
438 | 33d68b5f | ths | } |
439 | 33d68b5f | ths | } |
440 | 33d68b5f | ths | |
441 | f8a6ec58 | ths | #ifndef CONFIG_USER_ONLY
|
442 | c227f099 | Anthony Liguori | static void no_mmu_init (CPUMIPSState *env, const mips_def_t *def) |
443 | 29929e34 | ths | { |
444 | ead9360e | ths | env->tlb->nb_tlb = 1;
|
445 | ead9360e | ths | env->tlb->map_address = &no_mmu_map_address; |
446 | 29929e34 | ths | } |
447 | 29929e34 | ths | |
448 | c227f099 | Anthony Liguori | static void fixed_mmu_init (CPUMIPSState *env, const mips_def_t *def) |
449 | 29929e34 | ths | { |
450 | ead9360e | ths | env->tlb->nb_tlb = 1;
|
451 | ead9360e | ths | env->tlb->map_address = &fixed_mmu_map_address; |
452 | 29929e34 | ths | } |
453 | 29929e34 | ths | |
454 | c227f099 | Anthony Liguori | static void r4k_mmu_init (CPUMIPSState *env, const mips_def_t *def) |
455 | 29929e34 | ths | { |
456 | ead9360e | ths | env->tlb->nb_tlb = 1 + ((def->CP0_Config1 >> CP0C1_MMU) & 63); |
457 | ead9360e | ths | env->tlb->map_address = &r4k_map_address; |
458 | c01fccd2 | aurel32 | env->tlb->helper_tlbwi = r4k_helper_tlbwi; |
459 | c01fccd2 | aurel32 | env->tlb->helper_tlbwr = r4k_helper_tlbwr; |
460 | c01fccd2 | aurel32 | env->tlb->helper_tlbp = r4k_helper_tlbp; |
461 | c01fccd2 | aurel32 | env->tlb->helper_tlbr = r4k_helper_tlbr; |
462 | ead9360e | ths | } |
463 | ead9360e | ths | |
464 | c227f099 | Anthony Liguori | static void mmu_init (CPUMIPSState *env, const mips_def_t *def) |
465 | ead9360e | ths | { |
466 | ead9360e | ths | env->tlb = qemu_mallocz(sizeof(CPUMIPSTLBContext));
|
467 | ead9360e | ths | |
468 | 6d35524c | ths | switch (def->mmu_type) {
|
469 | 6d35524c | ths | case MMU_TYPE_NONE:
|
470 | ead9360e | ths | no_mmu_init(env, def); |
471 | ead9360e | ths | break;
|
472 | 6d35524c | ths | case MMU_TYPE_R4000:
|
473 | ead9360e | ths | r4k_mmu_init(env, def); |
474 | ead9360e | ths | break;
|
475 | 6d35524c | ths | case MMU_TYPE_FMT:
|
476 | ead9360e | ths | fixed_mmu_init(env, def); |
477 | ead9360e | ths | break;
|
478 | 6d35524c | ths | case MMU_TYPE_R3000:
|
479 | 6d35524c | ths | case MMU_TYPE_R6000:
|
480 | 6d35524c | ths | case MMU_TYPE_R8000:
|
481 | ead9360e | ths | default:
|
482 | ead9360e | ths | cpu_abort(env, "MMU type not supported\n");
|
483 | ead9360e | ths | } |
484 | 29929e34 | ths | } |
485 | f8a6ec58 | ths | #endif /* CONFIG_USER_ONLY */ |
486 | 29929e34 | ths | |
487 | c227f099 | Anthony Liguori | static void fpu_init (CPUMIPSState *env, const mips_def_t *def) |
488 | ead9360e | ths | { |
489 | f01be154 | ths | int i;
|
490 | f01be154 | ths | |
491 | f01be154 | ths | for (i = 0; i < MIPS_FPU_MAX; i++) |
492 | f01be154 | ths | env->fpus[i].fcr0 = def->CP1_fcr0; |
493 | ead9360e | ths | |
494 | f01be154 | ths | memcpy(&env->active_fpu, &env->fpus[0], sizeof(env->active_fpu)); |
495 | 932e71cd | aurel32 | #if defined(CONFIG_USER_ONLY)
|
496 | 932e71cd | aurel32 | if (env->CP0_Config1 & (1 << CP0C1_FP)) |
497 | 932e71cd | aurel32 | env->hflags |= MIPS_HFLAG_FPU; |
498 | 36271893 | ths | #ifdef TARGET_MIPS64
|
499 | 932e71cd | aurel32 | if (env->active_fpu.fcr0 & (1 << FCR0_F64)) |
500 | 932e71cd | aurel32 | env->hflags |= MIPS_HFLAG_F64; |
501 | 932e71cd | aurel32 | #endif
|
502 | 36271893 | ths | #endif
|
503 | ead9360e | ths | } |
504 | ead9360e | ths | |
505 | c227f099 | Anthony Liguori | static void mvp_init (CPUMIPSState *env, const mips_def_t *def) |
506 | ead9360e | ths | { |
507 | ead9360e | ths | env->mvp = qemu_mallocz(sizeof(CPUMIPSMVPContext));
|
508 | ead9360e | ths | |
509 | ead9360e | ths | /* MVPConf1 implemented, TLB sharable, no gating storage support,
|
510 | ead9360e | ths | programmable cache partitioning implemented, number of allocatable
|
511 | ead9360e | ths | and sharable TLB entries, MVP has allocatable TCs, 2 VPEs
|
512 | ead9360e | ths | implemented, 5 TCs implemented. */
|
513 | ead9360e | ths | env->mvp->CP0_MVPConf0 = (1 << CP0MVPC0_M) | (1 << CP0MVPC0_TLBS) | |
514 | ead9360e | ths | (0 << CP0MVPC0_GS) | (1 << CP0MVPC0_PCP) | |
515 | ead9360e | ths | // TODO: actually do 2 VPEs.
|
516 | ead9360e | ths | // (1 << CP0MVPC0_TCA) | (0x1 << CP0MVPC0_PVPE) |
|
517 | ead9360e | ths | // (0x04 << CP0MVPC0_PTC);
|
518 | ead9360e | ths | (1 << CP0MVPC0_TCA) | (0x0 << CP0MVPC0_PVPE) | |
519 | ead9360e | ths | (0x04 << CP0MVPC0_PTC);
|
520 | 932e71cd | aurel32 | #if !defined(CONFIG_USER_ONLY)
|
521 | 0eaef5aa | ths | /* Usermode has no TLB support */
|
522 | 932e71cd | aurel32 | env->mvp->CP0_MVPConf0 |= (env->tlb->nb_tlb << CP0MVPC0_PTLBE); |
523 | 932e71cd | aurel32 | #endif
|
524 | 0eaef5aa | ths | |
525 | ead9360e | ths | /* Allocatable CP1 have media extensions, allocatable CP1 have FP support,
|
526 | ead9360e | ths | no UDI implemented, no CP2 implemented, 1 CP1 implemented. */
|
527 | ead9360e | ths | env->mvp->CP0_MVPConf1 = (1 << CP0MVPC1_CIM) | (1 << CP0MVPC1_CIF) | |
528 | ead9360e | ths | (0x0 << CP0MVPC1_PCX) | (0x0 << CP0MVPC1_PCP2) | |
529 | ead9360e | ths | (0x1 << CP0MVPC1_PCP1);
|
530 | ead9360e | ths | } |