x86: prepare op_helper.c for splitting
[qemu.git] / target-arm / cpu.c
blobae5795337f74d8a278e9e9f8f3bf4d30087fec40
1 /*
2 * QEMU ARM CPU
4 * Copyright (c) 2012 SUSE LINUX Products GmbH
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see
18 * <http://www.gnu.org/licenses/gpl-2.0.html>
21 #include "cpu.h"
22 #include "qemu-common.h"
23 #if !defined(CONFIG_USER_ONLY)
24 #include "hw/loader.h"
25 #endif
26 #include "sysemu.h"
28 static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque)
30 /* Reset a single ARMCPRegInfo register */
31 ARMCPRegInfo *ri = value;
32 ARMCPU *cpu = opaque;
34 if (ri->type & ARM_CP_SPECIAL) {
35 return;
38 if (ri->resetfn) {
39 ri->resetfn(&cpu->env, ri);
40 return;
43 /* A zero offset is never possible as it would be regs[0]
44 * so we use it to indicate that reset is being handled elsewhere.
45 * This is basically only used for fields in non-core coprocessors
46 * (like the pxa2xx ones).
48 if (!ri->fieldoffset) {
49 return;
52 if (ri->type & ARM_CP_64BIT) {
53 CPREG_FIELD64(&cpu->env, ri) = ri->resetvalue;
54 } else {
55 CPREG_FIELD32(&cpu->env, ri) = ri->resetvalue;
59 /* CPUClass::reset() */
60 static void arm_cpu_reset(CPUState *s)
62 ARMCPU *cpu = ARM_CPU(s);
63 ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu);
64 CPUARMState *env = &cpu->env;
66 if (qemu_loglevel_mask(CPU_LOG_RESET)) {
67 qemu_log("CPU Reset (CPU %d)\n", env->cpu_index);
68 log_cpu_state(env, 0);
71 acc->parent_reset(s);
73 memset(env, 0, offsetof(CPUARMState, breakpoints));
74 g_hash_table_foreach(cpu->cp_regs, cp_reg_reset, cpu);
75 env->vfp.xregs[ARM_VFP_FPSID] = cpu->reset_fpsid;
76 env->vfp.xregs[ARM_VFP_MVFR0] = cpu->mvfr0;
77 env->vfp.xregs[ARM_VFP_MVFR1] = cpu->mvfr1;
79 if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
80 env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';
83 #if defined(CONFIG_USER_ONLY)
84 env->uncached_cpsr = ARM_CPU_MODE_USR;
85 /* For user mode we must enable access to coprocessors */
86 env->vfp.xregs[ARM_VFP_FPEXC] = 1 << 30;
87 if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
88 env->cp15.c15_cpar = 3;
89 } else if (arm_feature(env, ARM_FEATURE_XSCALE)) {
90 env->cp15.c15_cpar = 1;
92 #else
93 /* SVC mode with interrupts disabled. */
94 env->uncached_cpsr = ARM_CPU_MODE_SVC | CPSR_A | CPSR_F | CPSR_I;
95 /* On ARMv7-M the CPSR_I is the value of the PRIMASK register, and is
96 clear at reset. Initial SP and PC are loaded from ROM. */
97 if (IS_M(env)) {
98 uint32_t pc;
99 uint8_t *rom;
100 env->uncached_cpsr &= ~CPSR_I;
101 rom = rom_ptr(0);
102 if (rom) {
103 /* We should really use ldl_phys here, in case the guest
104 modified flash and reset itself. However images
105 loaded via -kernel have not been copied yet, so load the
106 values directly from there. */
107 env->regs[13] = ldl_p(rom);
108 pc = ldl_p(rom + 4);
109 env->thumb = pc & 1;
110 env->regs[15] = pc & ~1;
113 env->vfp.xregs[ARM_VFP_FPEXC] = 0;
114 #endif
115 set_flush_to_zero(1, &env->vfp.standard_fp_status);
116 set_flush_inputs_to_zero(1, &env->vfp.standard_fp_status);
117 set_default_nan_mode(1, &env->vfp.standard_fp_status);
118 set_float_detect_tininess(float_tininess_before_rounding,
119 &env->vfp.fp_status);
120 set_float_detect_tininess(float_tininess_before_rounding,
121 &env->vfp.standard_fp_status);
122 tlb_flush(env, 1);
123 /* Reset is a state change for some CPUARMState fields which we
124 * bake assumptions about into translated code, so we need to
125 * tb_flush().
127 tb_flush(env);
130 static inline void set_feature(CPUARMState *env, int feature)
132 env->features |= 1u << feature;
135 static void arm_cpu_initfn(Object *obj)
137 ARMCPU *cpu = ARM_CPU(obj);
139 cpu_exec_init(&cpu->env);
140 cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal,
141 g_free, g_free);
144 static void arm_cpu_finalizefn(Object *obj)
146 ARMCPU *cpu = ARM_CPU(obj);
147 g_hash_table_destroy(cpu->cp_regs);
150 void arm_cpu_realize(ARMCPU *cpu)
152 /* This function is called by cpu_arm_init() because it
153 * needs to do common actions based on feature bits, etc
154 * that have been set by the subclass init functions.
155 * When we have QOM realize support it should become
156 * a true realize function instead.
158 CPUARMState *env = &cpu->env;
159 /* Some features automatically imply others: */
160 if (arm_feature(env, ARM_FEATURE_V7)) {
161 set_feature(env, ARM_FEATURE_VAPA);
162 set_feature(env, ARM_FEATURE_THUMB2);
163 set_feature(env, ARM_FEATURE_MPIDR);
164 if (!arm_feature(env, ARM_FEATURE_M)) {
165 set_feature(env, ARM_FEATURE_V6K);
166 } else {
167 set_feature(env, ARM_FEATURE_V6);
170 if (arm_feature(env, ARM_FEATURE_V6K)) {
171 set_feature(env, ARM_FEATURE_V6);
172 set_feature(env, ARM_FEATURE_MVFR);
174 if (arm_feature(env, ARM_FEATURE_V6)) {
175 set_feature(env, ARM_FEATURE_V5);
176 if (!arm_feature(env, ARM_FEATURE_M)) {
177 set_feature(env, ARM_FEATURE_AUXCR);
180 if (arm_feature(env, ARM_FEATURE_V5)) {
181 set_feature(env, ARM_FEATURE_V4T);
183 if (arm_feature(env, ARM_FEATURE_M)) {
184 set_feature(env, ARM_FEATURE_THUMB_DIV);
186 if (arm_feature(env, ARM_FEATURE_ARM_DIV)) {
187 set_feature(env, ARM_FEATURE_THUMB_DIV);
189 if (arm_feature(env, ARM_FEATURE_VFP4)) {
190 set_feature(env, ARM_FEATURE_VFP3);
192 if (arm_feature(env, ARM_FEATURE_VFP3)) {
193 set_feature(env, ARM_FEATURE_VFP);
196 register_cp_regs_for_features(cpu);
199 /* CPU models */
201 static void arm926_initfn(Object *obj)
203 ARMCPU *cpu = ARM_CPU(obj);
204 set_feature(&cpu->env, ARM_FEATURE_V5);
205 set_feature(&cpu->env, ARM_FEATURE_VFP);
206 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
207 set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN);
208 cpu->midr = 0x41069265;
209 cpu->reset_fpsid = 0x41011090;
210 cpu->ctr = 0x1dd20d2;
211 cpu->reset_sctlr = 0x00090078;
214 static void arm946_initfn(Object *obj)
216 ARMCPU *cpu = ARM_CPU(obj);
217 set_feature(&cpu->env, ARM_FEATURE_V5);
218 set_feature(&cpu->env, ARM_FEATURE_MPU);
219 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
220 cpu->midr = 0x41059461;
221 cpu->ctr = 0x0f004006;
222 cpu->reset_sctlr = 0x00000078;
225 static void arm1026_initfn(Object *obj)
227 ARMCPU *cpu = ARM_CPU(obj);
228 set_feature(&cpu->env, ARM_FEATURE_V5);
229 set_feature(&cpu->env, ARM_FEATURE_VFP);
230 set_feature(&cpu->env, ARM_FEATURE_AUXCR);
231 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
232 set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN);
233 cpu->midr = 0x4106a262;
234 cpu->reset_fpsid = 0x410110a0;
235 cpu->ctr = 0x1dd20d2;
236 cpu->reset_sctlr = 0x00090078;
237 cpu->reset_auxcr = 1;
239 /* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */
240 ARMCPRegInfo ifar = {
241 .name = "IFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 1,
242 .access = PL1_RW,
243 .fieldoffset = offsetof(CPUARMState, cp15.c6_insn),
244 .resetvalue = 0
246 define_one_arm_cp_reg(cpu, &ifar);
250 static void arm1136_r2_initfn(Object *obj)
252 ARMCPU *cpu = ARM_CPU(obj);
253 /* What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an
254 * older core than plain "arm1136". In particular this does not
255 * have the v6K features.
256 * These ID register values are correct for 1136 but may be wrong
257 * for 1136_r2 (in particular r0p2 does not actually implement most
258 * of the ID registers).
260 set_feature(&cpu->env, ARM_FEATURE_V6);
261 set_feature(&cpu->env, ARM_FEATURE_VFP);
262 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
263 set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG);
264 set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS);
265 cpu->midr = 0x4107b362;
266 cpu->reset_fpsid = 0x410120b4;
267 cpu->mvfr0 = 0x11111111;
268 cpu->mvfr1 = 0x00000000;
269 cpu->ctr = 0x1dd20d2;
270 cpu->reset_sctlr = 0x00050078;
271 cpu->id_pfr0 = 0x111;
272 cpu->id_pfr1 = 0x1;
273 cpu->id_dfr0 = 0x2;
274 cpu->id_afr0 = 0x3;
275 cpu->id_mmfr0 = 0x01130003;
276 cpu->id_mmfr1 = 0x10030302;
277 cpu->id_mmfr2 = 0x01222110;
278 cpu->id_isar0 = 0x00140011;
279 cpu->id_isar1 = 0x12002111;
280 cpu->id_isar2 = 0x11231111;
281 cpu->id_isar3 = 0x01102131;
282 cpu->id_isar4 = 0x141;
283 cpu->reset_auxcr = 7;
286 static void arm1136_initfn(Object *obj)
288 ARMCPU *cpu = ARM_CPU(obj);
289 set_feature(&cpu->env, ARM_FEATURE_V6K);
290 set_feature(&cpu->env, ARM_FEATURE_V6);
291 set_feature(&cpu->env, ARM_FEATURE_VFP);
292 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
293 set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG);
294 set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS);
295 cpu->midr = 0x4117b363;
296 cpu->reset_fpsid = 0x410120b4;
297 cpu->mvfr0 = 0x11111111;
298 cpu->mvfr1 = 0x00000000;
299 cpu->ctr = 0x1dd20d2;
300 cpu->reset_sctlr = 0x00050078;
301 cpu->id_pfr0 = 0x111;
302 cpu->id_pfr1 = 0x1;
303 cpu->id_dfr0 = 0x2;
304 cpu->id_afr0 = 0x3;
305 cpu->id_mmfr0 = 0x01130003;
306 cpu->id_mmfr1 = 0x10030302;
307 cpu->id_mmfr2 = 0x01222110;
308 cpu->id_isar0 = 0x00140011;
309 cpu->id_isar1 = 0x12002111;
310 cpu->id_isar2 = 0x11231111;
311 cpu->id_isar3 = 0x01102131;
312 cpu->id_isar4 = 0x141;
313 cpu->reset_auxcr = 7;
316 static void arm1176_initfn(Object *obj)
318 ARMCPU *cpu = ARM_CPU(obj);
319 set_feature(&cpu->env, ARM_FEATURE_V6K);
320 set_feature(&cpu->env, ARM_FEATURE_VFP);
321 set_feature(&cpu->env, ARM_FEATURE_VAPA);
322 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
323 set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG);
324 set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS);
325 cpu->midr = 0x410fb767;
326 cpu->reset_fpsid = 0x410120b5;
327 cpu->mvfr0 = 0x11111111;
328 cpu->mvfr1 = 0x00000000;
329 cpu->ctr = 0x1dd20d2;
330 cpu->reset_sctlr = 0x00050078;
331 cpu->id_pfr0 = 0x111;
332 cpu->id_pfr1 = 0x11;
333 cpu->id_dfr0 = 0x33;
334 cpu->id_afr0 = 0;
335 cpu->id_mmfr0 = 0x01130003;
336 cpu->id_mmfr1 = 0x10030302;
337 cpu->id_mmfr2 = 0x01222100;
338 cpu->id_isar0 = 0x0140011;
339 cpu->id_isar1 = 0x12002111;
340 cpu->id_isar2 = 0x11231121;
341 cpu->id_isar3 = 0x01102131;
342 cpu->id_isar4 = 0x01141;
343 cpu->reset_auxcr = 7;
346 static void arm11mpcore_initfn(Object *obj)
348 ARMCPU *cpu = ARM_CPU(obj);
349 set_feature(&cpu->env, ARM_FEATURE_V6K);
350 set_feature(&cpu->env, ARM_FEATURE_VFP);
351 set_feature(&cpu->env, ARM_FEATURE_VAPA);
352 set_feature(&cpu->env, ARM_FEATURE_MPIDR);
353 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
354 cpu->midr = 0x410fb022;
355 cpu->reset_fpsid = 0x410120b4;
356 cpu->mvfr0 = 0x11111111;
357 cpu->mvfr1 = 0x00000000;
358 cpu->ctr = 0x1d192992; /* 32K icache 32K dcache */
359 cpu->id_pfr0 = 0x111;
360 cpu->id_pfr1 = 0x1;
361 cpu->id_dfr0 = 0;
362 cpu->id_afr0 = 0x2;
363 cpu->id_mmfr0 = 0x01100103;
364 cpu->id_mmfr1 = 0x10020302;
365 cpu->id_mmfr2 = 0x01222000;
366 cpu->id_isar0 = 0x00100011;
367 cpu->id_isar1 = 0x12002111;
368 cpu->id_isar2 = 0x11221011;
369 cpu->id_isar3 = 0x01102131;
370 cpu->id_isar4 = 0x141;
371 cpu->reset_auxcr = 1;
374 static void cortex_m3_initfn(Object *obj)
376 ARMCPU *cpu = ARM_CPU(obj);
377 set_feature(&cpu->env, ARM_FEATURE_V7);
378 set_feature(&cpu->env, ARM_FEATURE_M);
379 cpu->midr = 0x410fc231;
382 static const ARMCPRegInfo cortexa8_cp_reginfo[] = {
383 { .name = "L2LOCKDOWN", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 0,
384 .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
385 { .name = "L2AUXCR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2,
386 .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
387 REGINFO_SENTINEL
390 static void cortex_a8_initfn(Object *obj)
392 ARMCPU *cpu = ARM_CPU(obj);
393 set_feature(&cpu->env, ARM_FEATURE_V7);
394 set_feature(&cpu->env, ARM_FEATURE_VFP3);
395 set_feature(&cpu->env, ARM_FEATURE_NEON);
396 set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
397 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
398 cpu->midr = 0x410fc080;
399 cpu->reset_fpsid = 0x410330c0;
400 cpu->mvfr0 = 0x11110222;
401 cpu->mvfr1 = 0x00011100;
402 cpu->ctr = 0x82048004;
403 cpu->reset_sctlr = 0x00c50078;
404 cpu->id_pfr0 = 0x1031;
405 cpu->id_pfr1 = 0x11;
406 cpu->id_dfr0 = 0x400;
407 cpu->id_afr0 = 0;
408 cpu->id_mmfr0 = 0x31100003;
409 cpu->id_mmfr1 = 0x20000000;
410 cpu->id_mmfr2 = 0x01202000;
411 cpu->id_mmfr3 = 0x11;
412 cpu->id_isar0 = 0x00101111;
413 cpu->id_isar1 = 0x12112111;
414 cpu->id_isar2 = 0x21232031;
415 cpu->id_isar3 = 0x11112131;
416 cpu->id_isar4 = 0x00111142;
417 cpu->clidr = (1 << 27) | (2 << 24) | 3;
418 cpu->ccsidr[0] = 0xe007e01a; /* 16k L1 dcache. */
419 cpu->ccsidr[1] = 0x2007e01a; /* 16k L1 icache. */
420 cpu->ccsidr[2] = 0xf0000000; /* No L2 icache. */
421 cpu->reset_auxcr = 2;
422 define_arm_cp_regs(cpu, cortexa8_cp_reginfo);
425 static const ARMCPRegInfo cortexa9_cp_reginfo[] = {
426 /* power_control should be set to maximum latency. Again,
427 * default to 0 and set by private hook
429 { .name = "A9_PWRCTL", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 0,
430 .access = PL1_RW, .resetvalue = 0,
431 .fieldoffset = offsetof(CPUARMState, cp15.c15_power_control) },
432 { .name = "A9_DIAG", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 1,
433 .access = PL1_RW, .resetvalue = 0,
434 .fieldoffset = offsetof(CPUARMState, cp15.c15_diagnostic) },
435 { .name = "A9_PWRDIAG", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 2,
436 .access = PL1_RW, .resetvalue = 0,
437 .fieldoffset = offsetof(CPUARMState, cp15.c15_power_diagnostic) },
438 { .name = "NEONBUSY", .cp = 15, .crn = 15, .crm = 1, .opc1 = 0, .opc2 = 0,
439 .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
440 /* TLB lockdown control */
441 { .name = "TLB_LOCKR", .cp = 15, .crn = 15, .crm = 4, .opc1 = 5, .opc2 = 2,
442 .access = PL1_W, .resetvalue = 0, .type = ARM_CP_NOP },
443 { .name = "TLB_LOCKW", .cp = 15, .crn = 15, .crm = 4, .opc1 = 5, .opc2 = 4,
444 .access = PL1_W, .resetvalue = 0, .type = ARM_CP_NOP },
445 { .name = "TLB_VA", .cp = 15, .crn = 15, .crm = 5, .opc1 = 5, .opc2 = 2,
446 .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
447 { .name = "TLB_PA", .cp = 15, .crn = 15, .crm = 6, .opc1 = 5, .opc2 = 2,
448 .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
449 { .name = "TLB_ATTR", .cp = 15, .crn = 15, .crm = 7, .opc1 = 5, .opc2 = 2,
450 .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
451 REGINFO_SENTINEL
454 static void cortex_a9_initfn(Object *obj)
456 ARMCPU *cpu = ARM_CPU(obj);
457 set_feature(&cpu->env, ARM_FEATURE_V7);
458 set_feature(&cpu->env, ARM_FEATURE_VFP3);
459 set_feature(&cpu->env, ARM_FEATURE_VFP_FP16);
460 set_feature(&cpu->env, ARM_FEATURE_NEON);
461 set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
462 /* Note that A9 supports the MP extensions even for
463 * A9UP and single-core A9MP (which are both different
464 * and valid configurations; we don't model A9UP).
466 set_feature(&cpu->env, ARM_FEATURE_V7MP);
467 cpu->midr = 0x410fc090;
468 cpu->reset_fpsid = 0x41033090;
469 cpu->mvfr0 = 0x11110222;
470 cpu->mvfr1 = 0x01111111;
471 cpu->ctr = 0x80038003;
472 cpu->reset_sctlr = 0x00c50078;
473 cpu->id_pfr0 = 0x1031;
474 cpu->id_pfr1 = 0x11;
475 cpu->id_dfr0 = 0x000;
476 cpu->id_afr0 = 0;
477 cpu->id_mmfr0 = 0x00100103;
478 cpu->id_mmfr1 = 0x20000000;
479 cpu->id_mmfr2 = 0x01230000;
480 cpu->id_mmfr3 = 0x00002111;
481 cpu->id_isar0 = 0x00101111;
482 cpu->id_isar1 = 0x13112111;
483 cpu->id_isar2 = 0x21232041;
484 cpu->id_isar3 = 0x11112131;
485 cpu->id_isar4 = 0x00111142;
486 cpu->clidr = (1 << 27) | (1 << 24) | 3;
487 cpu->ccsidr[0] = 0xe00fe015; /* 16k L1 dcache. */
488 cpu->ccsidr[1] = 0x200fe015; /* 16k L1 icache. */
490 ARMCPRegInfo cbar = {
491 .name = "CBAR", .cp = 15, .crn = 15, .crm = 0, .opc1 = 4,
492 .opc2 = 0, .access = PL1_R|PL3_W, .resetvalue = cpu->reset_cbar,
493 .fieldoffset = offsetof(CPUARMState, cp15.c15_config_base_address)
495 define_one_arm_cp_reg(cpu, &cbar);
496 define_arm_cp_regs(cpu, cortexa9_cp_reginfo);
500 #ifndef CONFIG_USER_ONLY
501 static int a15_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri,
502 uint64_t *value)
504 /* Linux wants the number of processors from here.
505 * Might as well set the interrupt-controller bit too.
507 *value = ((smp_cpus - 1) << 24) | (1 << 23);
508 return 0;
510 #endif
512 static const ARMCPRegInfo cortexa15_cp_reginfo[] = {
513 #ifndef CONFIG_USER_ONLY
514 { .name = "L2CTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2,
515 .access = PL1_RW, .resetvalue = 0, .readfn = a15_l2ctlr_read,
516 .writefn = arm_cp_write_ignore, },
517 #endif
518 { .name = "L2ECTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 3,
519 .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
520 REGINFO_SENTINEL
523 static void cortex_a15_initfn(Object *obj)
525 ARMCPU *cpu = ARM_CPU(obj);
526 set_feature(&cpu->env, ARM_FEATURE_V7);
527 set_feature(&cpu->env, ARM_FEATURE_VFP4);
528 set_feature(&cpu->env, ARM_FEATURE_VFP_FP16);
529 set_feature(&cpu->env, ARM_FEATURE_NEON);
530 set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
531 set_feature(&cpu->env, ARM_FEATURE_ARM_DIV);
532 set_feature(&cpu->env, ARM_FEATURE_V7MP);
533 set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
534 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
535 cpu->midr = 0x412fc0f1;
536 cpu->reset_fpsid = 0x410430f0;
537 cpu->mvfr0 = 0x10110222;
538 cpu->mvfr1 = 0x11111111;
539 cpu->ctr = 0x8444c004;
540 cpu->reset_sctlr = 0x00c50078;
541 cpu->id_pfr0 = 0x00001131;
542 cpu->id_pfr1 = 0x00011011;
543 cpu->id_dfr0 = 0x02010555;
544 cpu->id_afr0 = 0x00000000;
545 cpu->id_mmfr0 = 0x10201105;
546 cpu->id_mmfr1 = 0x20000000;
547 cpu->id_mmfr2 = 0x01240000;
548 cpu->id_mmfr3 = 0x02102211;
549 cpu->id_isar0 = 0x02101110;
550 cpu->id_isar1 = 0x13112111;
551 cpu->id_isar2 = 0x21232041;
552 cpu->id_isar3 = 0x11112131;
553 cpu->id_isar4 = 0x10011142;
554 cpu->clidr = 0x0a200023;
555 cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */
556 cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */
557 cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
558 define_arm_cp_regs(cpu, cortexa15_cp_reginfo);
561 static void ti925t_initfn(Object *obj)
563 ARMCPU *cpu = ARM_CPU(obj);
564 set_feature(&cpu->env, ARM_FEATURE_V4T);
565 set_feature(&cpu->env, ARM_FEATURE_OMAPCP);
566 cpu->midr = ARM_CPUID_TI925T;
567 cpu->ctr = 0x5109149;
568 cpu->reset_sctlr = 0x00000070;
571 static void sa1100_initfn(Object *obj)
573 ARMCPU *cpu = ARM_CPU(obj);
574 set_feature(&cpu->env, ARM_FEATURE_STRONGARM);
575 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
576 cpu->midr = 0x4401A11B;
577 cpu->reset_sctlr = 0x00000070;
580 static void sa1110_initfn(Object *obj)
582 ARMCPU *cpu = ARM_CPU(obj);
583 set_feature(&cpu->env, ARM_FEATURE_STRONGARM);
584 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
585 cpu->midr = 0x6901B119;
586 cpu->reset_sctlr = 0x00000070;
589 static void pxa250_initfn(Object *obj)
591 ARMCPU *cpu = ARM_CPU(obj);
592 set_feature(&cpu->env, ARM_FEATURE_V5);
593 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
594 cpu->midr = 0x69052100;
595 cpu->ctr = 0xd172172;
596 cpu->reset_sctlr = 0x00000078;
599 static void pxa255_initfn(Object *obj)
601 ARMCPU *cpu = ARM_CPU(obj);
602 set_feature(&cpu->env, ARM_FEATURE_V5);
603 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
604 cpu->midr = 0x69052d00;
605 cpu->ctr = 0xd172172;
606 cpu->reset_sctlr = 0x00000078;
609 static void pxa260_initfn(Object *obj)
611 ARMCPU *cpu = ARM_CPU(obj);
612 set_feature(&cpu->env, ARM_FEATURE_V5);
613 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
614 cpu->midr = 0x69052903;
615 cpu->ctr = 0xd172172;
616 cpu->reset_sctlr = 0x00000078;
619 static void pxa261_initfn(Object *obj)
621 ARMCPU *cpu = ARM_CPU(obj);
622 set_feature(&cpu->env, ARM_FEATURE_V5);
623 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
624 cpu->midr = 0x69052d05;
625 cpu->ctr = 0xd172172;
626 cpu->reset_sctlr = 0x00000078;
629 static void pxa262_initfn(Object *obj)
631 ARMCPU *cpu = ARM_CPU(obj);
632 set_feature(&cpu->env, ARM_FEATURE_V5);
633 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
634 cpu->midr = 0x69052d06;
635 cpu->ctr = 0xd172172;
636 cpu->reset_sctlr = 0x00000078;
639 static void pxa270a0_initfn(Object *obj)
641 ARMCPU *cpu = ARM_CPU(obj);
642 set_feature(&cpu->env, ARM_FEATURE_V5);
643 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
644 set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
645 cpu->midr = 0x69054110;
646 cpu->ctr = 0xd172172;
647 cpu->reset_sctlr = 0x00000078;
650 static void pxa270a1_initfn(Object *obj)
652 ARMCPU *cpu = ARM_CPU(obj);
653 set_feature(&cpu->env, ARM_FEATURE_V5);
654 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
655 set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
656 cpu->midr = 0x69054111;
657 cpu->ctr = 0xd172172;
658 cpu->reset_sctlr = 0x00000078;
661 static void pxa270b0_initfn(Object *obj)
663 ARMCPU *cpu = ARM_CPU(obj);
664 set_feature(&cpu->env, ARM_FEATURE_V5);
665 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
666 set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
667 cpu->midr = 0x69054112;
668 cpu->ctr = 0xd172172;
669 cpu->reset_sctlr = 0x00000078;
672 static void pxa270b1_initfn(Object *obj)
674 ARMCPU *cpu = ARM_CPU(obj);
675 set_feature(&cpu->env, ARM_FEATURE_V5);
676 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
677 set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
678 cpu->midr = 0x69054113;
679 cpu->ctr = 0xd172172;
680 cpu->reset_sctlr = 0x00000078;
683 static void pxa270c0_initfn(Object *obj)
685 ARMCPU *cpu = ARM_CPU(obj);
686 set_feature(&cpu->env, ARM_FEATURE_V5);
687 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
688 set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
689 cpu->midr = 0x69054114;
690 cpu->ctr = 0xd172172;
691 cpu->reset_sctlr = 0x00000078;
694 static void pxa270c5_initfn(Object *obj)
696 ARMCPU *cpu = ARM_CPU(obj);
697 set_feature(&cpu->env, ARM_FEATURE_V5);
698 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
699 set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
700 cpu->midr = 0x69054117;
701 cpu->ctr = 0xd172172;
702 cpu->reset_sctlr = 0x00000078;
705 static void arm_any_initfn(Object *obj)
707 ARMCPU *cpu = ARM_CPU(obj);
708 set_feature(&cpu->env, ARM_FEATURE_V7);
709 set_feature(&cpu->env, ARM_FEATURE_VFP4);
710 set_feature(&cpu->env, ARM_FEATURE_VFP_FP16);
711 set_feature(&cpu->env, ARM_FEATURE_NEON);
712 set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
713 set_feature(&cpu->env, ARM_FEATURE_ARM_DIV);
714 set_feature(&cpu->env, ARM_FEATURE_V7MP);
715 cpu->midr = 0xffffffff;
718 typedef struct ARMCPUInfo {
719 const char *name;
720 void (*initfn)(Object *obj);
721 } ARMCPUInfo;
723 static const ARMCPUInfo arm_cpus[] = {
724 { .name = "arm926", .initfn = arm926_initfn },
725 { .name = "arm946", .initfn = arm946_initfn },
726 { .name = "arm1026", .initfn = arm1026_initfn },
727 /* What QEMU calls "arm1136-r2" is actually the 1136 r0p2, i.e. an
728 * older core than plain "arm1136". In particular this does not
729 * have the v6K features.
731 { .name = "arm1136-r2", .initfn = arm1136_r2_initfn },
732 { .name = "arm1136", .initfn = arm1136_initfn },
733 { .name = "arm1176", .initfn = arm1176_initfn },
734 { .name = "arm11mpcore", .initfn = arm11mpcore_initfn },
735 { .name = "cortex-m3", .initfn = cortex_m3_initfn },
736 { .name = "cortex-a8", .initfn = cortex_a8_initfn },
737 { .name = "cortex-a9", .initfn = cortex_a9_initfn },
738 { .name = "cortex-a15", .initfn = cortex_a15_initfn },
739 { .name = "ti925t", .initfn = ti925t_initfn },
740 { .name = "sa1100", .initfn = sa1100_initfn },
741 { .name = "sa1110", .initfn = sa1110_initfn },
742 { .name = "pxa250", .initfn = pxa250_initfn },
743 { .name = "pxa255", .initfn = pxa255_initfn },
744 { .name = "pxa260", .initfn = pxa260_initfn },
745 { .name = "pxa261", .initfn = pxa261_initfn },
746 { .name = "pxa262", .initfn = pxa262_initfn },
747 /* "pxa270" is an alias for "pxa270-a0" */
748 { .name = "pxa270", .initfn = pxa270a0_initfn },
749 { .name = "pxa270-a0", .initfn = pxa270a0_initfn },
750 { .name = "pxa270-a1", .initfn = pxa270a1_initfn },
751 { .name = "pxa270-b0", .initfn = pxa270b0_initfn },
752 { .name = "pxa270-b1", .initfn = pxa270b1_initfn },
753 { .name = "pxa270-c0", .initfn = pxa270c0_initfn },
754 { .name = "pxa270-c5", .initfn = pxa270c5_initfn },
755 { .name = "any", .initfn = arm_any_initfn },
758 static void arm_cpu_class_init(ObjectClass *oc, void *data)
760 ARMCPUClass *acc = ARM_CPU_CLASS(oc);
761 CPUClass *cc = CPU_CLASS(acc);
763 acc->parent_reset = cc->reset;
764 cc->reset = arm_cpu_reset;
767 static void cpu_register(const ARMCPUInfo *info)
769 TypeInfo type_info = {
770 .name = info->name,
771 .parent = TYPE_ARM_CPU,
772 .instance_size = sizeof(ARMCPU),
773 .instance_init = info->initfn,
774 .class_size = sizeof(ARMCPUClass),
777 type_register_static(&type_info);
780 static const TypeInfo arm_cpu_type_info = {
781 .name = TYPE_ARM_CPU,
782 .parent = TYPE_CPU,
783 .instance_size = sizeof(ARMCPU),
784 .instance_init = arm_cpu_initfn,
785 .instance_finalize = arm_cpu_finalizefn,
786 .abstract = true,
787 .class_size = sizeof(ARMCPUClass),
788 .class_init = arm_cpu_class_init,
791 static void arm_cpu_register_types(void)
793 int i;
795 type_register_static(&arm_cpu_type_info);
796 for (i = 0; i < ARRAY_SIZE(arm_cpus); i++) {
797 cpu_register(&arm_cpus[i]);
801 type_init(arm_cpu_register_types)