hw/usb: Include USB files only if necessary
[qemu/kevin.git] / target-arm / cpu.c
blob986f04cfd62f6bf05bcf8bf813861a0ded14c695
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 "internals.h"
23 #include "qemu-common.h"
24 #include "hw/qdev-properties.h"
25 #include "qapi/qmp/qerror.h"
26 #if !defined(CONFIG_USER_ONLY)
27 #include "hw/loader.h"
28 #endif
29 #include "hw/arm/arm.h"
30 #include "sysemu/sysemu.h"
31 #include "sysemu/kvm.h"
32 #include "kvm_arm.h"
34 static void arm_cpu_set_pc(CPUState *cs, vaddr value)
36 ARMCPU *cpu = ARM_CPU(cs);
38 cpu->env.regs[15] = value;
41 static bool arm_cpu_has_work(CPUState *cs)
43 ARMCPU *cpu = ARM_CPU(cs);
45 return !cpu->powered_off
46 && cs->interrupt_request &
47 (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD
48 | CPU_INTERRUPT_VFIQ | CPU_INTERRUPT_VIRQ
49 | CPU_INTERRUPT_EXITTB);
52 static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque)
54 /* Reset a single ARMCPRegInfo register */
55 ARMCPRegInfo *ri = value;
56 ARMCPU *cpu = opaque;
58 if (ri->type & ARM_CP_SPECIAL) {
59 return;
62 if (ri->resetfn) {
63 ri->resetfn(&cpu->env, ri);
64 return;
67 /* A zero offset is never possible as it would be regs[0]
68 * so we use it to indicate that reset is being handled elsewhere.
69 * This is basically only used for fields in non-core coprocessors
70 * (like the pxa2xx ones).
72 if (!ri->fieldoffset) {
73 return;
76 if (cpreg_field_is_64bit(ri)) {
77 CPREG_FIELD64(&cpu->env, ri) = ri->resetvalue;
78 } else {
79 CPREG_FIELD32(&cpu->env, ri) = ri->resetvalue;
83 /* CPUClass::reset() */
84 static void arm_cpu_reset(CPUState *s)
86 ARMCPU *cpu = ARM_CPU(s);
87 ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu);
88 CPUARMState *env = &cpu->env;
90 acc->parent_reset(s);
92 memset(env, 0, offsetof(CPUARMState, features));
93 g_hash_table_foreach(cpu->cp_regs, cp_reg_reset, cpu);
94 env->vfp.xregs[ARM_VFP_FPSID] = cpu->reset_fpsid;
95 env->vfp.xregs[ARM_VFP_MVFR0] = cpu->mvfr0;
96 env->vfp.xregs[ARM_VFP_MVFR1] = cpu->mvfr1;
97 env->vfp.xregs[ARM_VFP_MVFR2] = cpu->mvfr2;
99 cpu->powered_off = cpu->start_powered_off;
100 s->halted = cpu->start_powered_off;
102 if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
103 env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';
106 if (arm_feature(env, ARM_FEATURE_AARCH64)) {
107 /* 64 bit CPUs always start in 64 bit mode */
108 env->aarch64 = 1;
109 #if defined(CONFIG_USER_ONLY)
110 env->pstate = PSTATE_MODE_EL0t;
111 /* Userspace expects access to DC ZVA, CTL_EL0 and the cache ops */
112 env->cp15.sctlr_el[1] |= SCTLR_UCT | SCTLR_UCI | SCTLR_DZE;
113 /* and to the FP/Neon instructions */
114 env->cp15.c1_coproc = deposit64(env->cp15.c1_coproc, 20, 2, 3);
115 #else
116 /* Reset into the highest available EL */
117 if (arm_feature(env, ARM_FEATURE_EL3)) {
118 env->pstate = PSTATE_MODE_EL3h;
119 } else if (arm_feature(env, ARM_FEATURE_EL2)) {
120 env->pstate = PSTATE_MODE_EL2h;
121 } else {
122 env->pstate = PSTATE_MODE_EL1h;
124 env->pc = cpu->rvbar;
125 #endif
126 } else {
127 #if defined(CONFIG_USER_ONLY)
128 /* Userspace expects access to cp10 and cp11 for FP/Neon */
129 env->cp15.c1_coproc = deposit64(env->cp15.c1_coproc, 20, 4, 0xf);
130 #endif
133 #if defined(CONFIG_USER_ONLY)
134 env->uncached_cpsr = ARM_CPU_MODE_USR;
135 /* For user mode we must enable access to coprocessors */
136 env->vfp.xregs[ARM_VFP_FPEXC] = 1 << 30;
137 if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
138 env->cp15.c15_cpar = 3;
139 } else if (arm_feature(env, ARM_FEATURE_XSCALE)) {
140 env->cp15.c15_cpar = 1;
142 #else
143 /* SVC mode with interrupts disabled. */
144 env->uncached_cpsr = ARM_CPU_MODE_SVC;
145 env->daif = PSTATE_D | PSTATE_A | PSTATE_I | PSTATE_F;
146 /* On ARMv7-M the CPSR_I is the value of the PRIMASK register, and is
147 * clear at reset. Initial SP and PC are loaded from ROM.
149 if (IS_M(env)) {
150 uint32_t initial_msp; /* Loaded from 0x0 */
151 uint32_t initial_pc; /* Loaded from 0x4 */
152 uint8_t *rom;
154 env->daif &= ~PSTATE_I;
155 rom = rom_ptr(0);
156 if (rom) {
157 /* Address zero is covered by ROM which hasn't yet been
158 * copied into physical memory.
160 initial_msp = ldl_p(rom);
161 initial_pc = ldl_p(rom + 4);
162 } else {
163 /* Address zero not covered by a ROM blob, or the ROM blob
164 * is in non-modifiable memory and this is a second reset after
165 * it got copied into memory. In the latter case, rom_ptr
166 * will return a NULL pointer and we should use ldl_phys instead.
168 initial_msp = ldl_phys(s->as, 0);
169 initial_pc = ldl_phys(s->as, 4);
172 env->regs[13] = initial_msp & 0xFFFFFFFC;
173 env->regs[15] = initial_pc & ~1;
174 env->thumb = initial_pc & 1;
177 /* AArch32 has a hard highvec setting of 0xFFFF0000. If we are currently
178 * executing as AArch32 then check if highvecs are enabled and
179 * adjust the PC accordingly.
181 if (A32_BANKED_CURRENT_REG_GET(env, sctlr) & SCTLR_V) {
182 env->regs[15] = 0xFFFF0000;
185 env->vfp.xregs[ARM_VFP_FPEXC] = 0;
186 #endif
187 set_flush_to_zero(1, &env->vfp.standard_fp_status);
188 set_flush_inputs_to_zero(1, &env->vfp.standard_fp_status);
189 set_default_nan_mode(1, &env->vfp.standard_fp_status);
190 set_float_detect_tininess(float_tininess_before_rounding,
191 &env->vfp.fp_status);
192 set_float_detect_tininess(float_tininess_before_rounding,
193 &env->vfp.standard_fp_status);
194 tlb_flush(s, 1);
196 #ifndef CONFIG_USER_ONLY
197 if (kvm_enabled()) {
198 kvm_arm_reset_vcpu(cpu);
200 #endif
202 hw_breakpoint_update_all(cpu);
203 hw_watchpoint_update_all(cpu);
206 bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
208 CPUClass *cc = CPU_GET_CLASS(cs);
209 bool ret = false;
211 if (interrupt_request & CPU_INTERRUPT_FIQ
212 && arm_excp_unmasked(cs, EXCP_FIQ)) {
213 cs->exception_index = EXCP_FIQ;
214 cc->do_interrupt(cs);
215 ret = true;
217 if (interrupt_request & CPU_INTERRUPT_HARD
218 && arm_excp_unmasked(cs, EXCP_IRQ)) {
219 cs->exception_index = EXCP_IRQ;
220 cc->do_interrupt(cs);
221 ret = true;
223 if (interrupt_request & CPU_INTERRUPT_VIRQ
224 && arm_excp_unmasked(cs, EXCP_VIRQ)) {
225 cs->exception_index = EXCP_VIRQ;
226 cc->do_interrupt(cs);
227 ret = true;
229 if (interrupt_request & CPU_INTERRUPT_VFIQ
230 && arm_excp_unmasked(cs, EXCP_VFIQ)) {
231 cs->exception_index = EXCP_VFIQ;
232 cc->do_interrupt(cs);
233 ret = true;
236 return ret;
239 #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
240 static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
242 CPUClass *cc = CPU_GET_CLASS(cs);
243 ARMCPU *cpu = ARM_CPU(cs);
244 CPUARMState *env = &cpu->env;
245 bool ret = false;
248 if (interrupt_request & CPU_INTERRUPT_FIQ
249 && !(env->daif & PSTATE_F)) {
250 cs->exception_index = EXCP_FIQ;
251 cc->do_interrupt(cs);
252 ret = true;
254 /* ARMv7-M interrupt return works by loading a magic value
255 * into the PC. On real hardware the load causes the
256 * return to occur. The qemu implementation performs the
257 * jump normally, then does the exception return when the
258 * CPU tries to execute code at the magic address.
259 * This will cause the magic PC value to be pushed to
260 * the stack if an interrupt occurred at the wrong time.
261 * We avoid this by disabling interrupts when
262 * pc contains a magic address.
264 if (interrupt_request & CPU_INTERRUPT_HARD
265 && !(env->daif & PSTATE_I)
266 && (env->regs[15] < 0xfffffff0)) {
267 cs->exception_index = EXCP_IRQ;
268 cc->do_interrupt(cs);
269 ret = true;
271 return ret;
273 #endif
275 #ifndef CONFIG_USER_ONLY
276 static void arm_cpu_set_irq(void *opaque, int irq, int level)
278 ARMCPU *cpu = opaque;
279 CPUARMState *env = &cpu->env;
280 CPUState *cs = CPU(cpu);
281 static const int mask[] = {
282 [ARM_CPU_IRQ] = CPU_INTERRUPT_HARD,
283 [ARM_CPU_FIQ] = CPU_INTERRUPT_FIQ,
284 [ARM_CPU_VIRQ] = CPU_INTERRUPT_VIRQ,
285 [ARM_CPU_VFIQ] = CPU_INTERRUPT_VFIQ
288 switch (irq) {
289 case ARM_CPU_VIRQ:
290 case ARM_CPU_VFIQ:
291 if (!arm_feature(env, ARM_FEATURE_EL2)) {
292 hw_error("%s: Virtual interrupt line %d with no EL2 support\n",
293 __func__, irq);
295 /* fall through */
296 case ARM_CPU_IRQ:
297 case ARM_CPU_FIQ:
298 if (level) {
299 cpu_interrupt(cs, mask[irq]);
300 } else {
301 cpu_reset_interrupt(cs, mask[irq]);
303 break;
304 default:
305 hw_error("arm_cpu_set_irq: Bad interrupt line %d\n", irq);
309 static void arm_cpu_kvm_set_irq(void *opaque, int irq, int level)
311 #ifdef CONFIG_KVM
312 ARMCPU *cpu = opaque;
313 CPUState *cs = CPU(cpu);
314 int kvm_irq = KVM_ARM_IRQ_TYPE_CPU << KVM_ARM_IRQ_TYPE_SHIFT;
316 switch (irq) {
317 case ARM_CPU_IRQ:
318 kvm_irq |= KVM_ARM_IRQ_CPU_IRQ;
319 break;
320 case ARM_CPU_FIQ:
321 kvm_irq |= KVM_ARM_IRQ_CPU_FIQ;
322 break;
323 default:
324 hw_error("arm_cpu_kvm_set_irq: Bad interrupt line %d\n", irq);
326 kvm_irq |= cs->cpu_index << KVM_ARM_IRQ_VCPU_SHIFT;
327 kvm_set_irq(kvm_state, kvm_irq, level ? 1 : 0);
328 #endif
331 static bool arm_cpu_is_big_endian(CPUState *cs)
333 ARMCPU *cpu = ARM_CPU(cs);
334 CPUARMState *env = &cpu->env;
335 int cur_el;
337 cpu_synchronize_state(cs);
339 /* In 32bit guest endianness is determined by looking at CPSR's E bit */
340 if (!is_a64(env)) {
341 return (env->uncached_cpsr & CPSR_E) ? 1 : 0;
344 cur_el = arm_current_el(env);
346 if (cur_el == 0) {
347 return (env->cp15.sctlr_el[1] & SCTLR_E0E) != 0;
350 return (env->cp15.sctlr_el[cur_el] & SCTLR_EE) != 0;
353 #endif
355 static inline void set_feature(CPUARMState *env, int feature)
357 env->features |= 1ULL << feature;
360 static inline void unset_feature(CPUARMState *env, int feature)
362 env->features &= ~(1ULL << feature);
365 static void arm_cpu_initfn(Object *obj)
367 CPUState *cs = CPU(obj);
368 ARMCPU *cpu = ARM_CPU(obj);
369 static bool inited;
371 cs->env_ptr = &cpu->env;
372 cpu_exec_init(&cpu->env);
373 cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal,
374 g_free, g_free);
376 #ifndef CONFIG_USER_ONLY
377 /* Our inbound IRQ and FIQ lines */
378 if (kvm_enabled()) {
379 /* VIRQ and VFIQ are unused with KVM but we add them to maintain
380 * the same interface as non-KVM CPUs.
382 qdev_init_gpio_in(DEVICE(cpu), arm_cpu_kvm_set_irq, 4);
383 } else {
384 qdev_init_gpio_in(DEVICE(cpu), arm_cpu_set_irq, 4);
387 cpu->gt_timer[GTIMER_PHYS] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE,
388 arm_gt_ptimer_cb, cpu);
389 cpu->gt_timer[GTIMER_VIRT] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE,
390 arm_gt_vtimer_cb, cpu);
391 qdev_init_gpio_out(DEVICE(cpu), cpu->gt_timer_outputs,
392 ARRAY_SIZE(cpu->gt_timer_outputs));
393 #endif
395 /* DTB consumers generally don't in fact care what the 'compatible'
396 * string is, so always provide some string and trust that a hypothetical
397 * picky DTB consumer will also provide a helpful error message.
399 cpu->dtb_compatible = "qemu,unknown";
400 cpu->psci_version = 1; /* By default assume PSCI v0.1 */
401 cpu->kvm_target = QEMU_KVM_ARM_TARGET_NONE;
403 if (tcg_enabled()) {
404 cpu->psci_version = 2; /* TCG implements PSCI 0.2 */
405 if (!inited) {
406 inited = true;
407 arm_translate_init();
412 static Property arm_cpu_reset_cbar_property =
413 DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0);
415 static Property arm_cpu_reset_hivecs_property =
416 DEFINE_PROP_BOOL("reset-hivecs", ARMCPU, reset_hivecs, false);
418 static Property arm_cpu_rvbar_property =
419 DEFINE_PROP_UINT64("rvbar", ARMCPU, rvbar, 0);
421 static Property arm_cpu_has_el3_property =
422 DEFINE_PROP_BOOL("has_el3", ARMCPU, has_el3, true);
424 static void arm_cpu_post_init(Object *obj)
426 ARMCPU *cpu = ARM_CPU(obj);
428 if (arm_feature(&cpu->env, ARM_FEATURE_CBAR) ||
429 arm_feature(&cpu->env, ARM_FEATURE_CBAR_RO)) {
430 qdev_property_add_static(DEVICE(obj), &arm_cpu_reset_cbar_property,
431 &error_abort);
434 if (!arm_feature(&cpu->env, ARM_FEATURE_M)) {
435 qdev_property_add_static(DEVICE(obj), &arm_cpu_reset_hivecs_property,
436 &error_abort);
439 if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
440 qdev_property_add_static(DEVICE(obj), &arm_cpu_rvbar_property,
441 &error_abort);
444 if (arm_feature(&cpu->env, ARM_FEATURE_EL3)) {
445 /* Add the has_el3 state CPU property only if EL3 is allowed. This will
446 * prevent "has_el3" from existing on CPUs which cannot support EL3.
448 qdev_property_add_static(DEVICE(obj), &arm_cpu_has_el3_property,
449 &error_abort);
453 static void arm_cpu_finalizefn(Object *obj)
455 ARMCPU *cpu = ARM_CPU(obj);
456 g_hash_table_destroy(cpu->cp_regs);
459 static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
461 CPUState *cs = CPU(dev);
462 ARMCPU *cpu = ARM_CPU(dev);
463 ARMCPUClass *acc = ARM_CPU_GET_CLASS(dev);
464 CPUARMState *env = &cpu->env;
466 /* Some features automatically imply others: */
467 if (arm_feature(env, ARM_FEATURE_V8)) {
468 set_feature(env, ARM_FEATURE_V7);
469 set_feature(env, ARM_FEATURE_ARM_DIV);
470 set_feature(env, ARM_FEATURE_LPAE);
472 if (arm_feature(env, ARM_FEATURE_V7)) {
473 set_feature(env, ARM_FEATURE_VAPA);
474 set_feature(env, ARM_FEATURE_THUMB2);
475 set_feature(env, ARM_FEATURE_MPIDR);
476 if (!arm_feature(env, ARM_FEATURE_M)) {
477 set_feature(env, ARM_FEATURE_V6K);
478 } else {
479 set_feature(env, ARM_FEATURE_V6);
482 if (arm_feature(env, ARM_FEATURE_V6K)) {
483 set_feature(env, ARM_FEATURE_V6);
484 set_feature(env, ARM_FEATURE_MVFR);
486 if (arm_feature(env, ARM_FEATURE_V6)) {
487 set_feature(env, ARM_FEATURE_V5);
488 if (!arm_feature(env, ARM_FEATURE_M)) {
489 set_feature(env, ARM_FEATURE_AUXCR);
492 if (arm_feature(env, ARM_FEATURE_V5)) {
493 set_feature(env, ARM_FEATURE_V4T);
495 if (arm_feature(env, ARM_FEATURE_M)) {
496 set_feature(env, ARM_FEATURE_THUMB_DIV);
498 if (arm_feature(env, ARM_FEATURE_ARM_DIV)) {
499 set_feature(env, ARM_FEATURE_THUMB_DIV);
501 if (arm_feature(env, ARM_FEATURE_VFP4)) {
502 set_feature(env, ARM_FEATURE_VFP3);
503 set_feature(env, ARM_FEATURE_VFP_FP16);
505 if (arm_feature(env, ARM_FEATURE_VFP3)) {
506 set_feature(env, ARM_FEATURE_VFP);
508 if (arm_feature(env, ARM_FEATURE_LPAE)) {
509 set_feature(env, ARM_FEATURE_V7MP);
510 set_feature(env, ARM_FEATURE_PXN);
512 if (arm_feature(env, ARM_FEATURE_CBAR_RO)) {
513 set_feature(env, ARM_FEATURE_CBAR);
516 if (cpu->reset_hivecs) {
517 cpu->reset_sctlr |= (1 << 13);
520 if (!cpu->has_el3) {
521 /* If the has_el3 CPU property is disabled then we need to disable the
522 * feature.
524 unset_feature(env, ARM_FEATURE_EL3);
526 /* Disable the security extension feature bits in the processor feature
527 * register as well. This is id_pfr1[7:4].
529 cpu->id_pfr1 &= ~0xf0;
532 register_cp_regs_for_features(cpu);
533 arm_cpu_register_gdb_regs_for_features(cpu);
535 init_cpreg_list(cpu);
537 qemu_init_vcpu(cs);
538 cpu_reset(cs);
540 acc->parent_realize(dev, errp);
543 static ObjectClass *arm_cpu_class_by_name(const char *cpu_model)
545 ObjectClass *oc;
546 char *typename;
547 char **cpuname;
549 if (!cpu_model) {
550 return NULL;
553 cpuname = g_strsplit(cpu_model, ",", 1);
554 typename = g_strdup_printf("%s-" TYPE_ARM_CPU, cpuname[0]);
555 oc = object_class_by_name(typename);
556 g_strfreev(cpuname);
557 g_free(typename);
558 if (!oc || !object_class_dynamic_cast(oc, TYPE_ARM_CPU) ||
559 object_class_is_abstract(oc)) {
560 return NULL;
562 return oc;
565 /* CPU models. These are not needed for the AArch64 linux-user build. */
566 #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
568 static void arm926_initfn(Object *obj)
570 ARMCPU *cpu = ARM_CPU(obj);
572 cpu->dtb_compatible = "arm,arm926";
573 set_feature(&cpu->env, ARM_FEATURE_V5);
574 set_feature(&cpu->env, ARM_FEATURE_VFP);
575 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
576 set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN);
577 cpu->midr = 0x41069265;
578 cpu->reset_fpsid = 0x41011090;
579 cpu->ctr = 0x1dd20d2;
580 cpu->reset_sctlr = 0x00090078;
583 static void arm946_initfn(Object *obj)
585 ARMCPU *cpu = ARM_CPU(obj);
587 cpu->dtb_compatible = "arm,arm946";
588 set_feature(&cpu->env, ARM_FEATURE_V5);
589 set_feature(&cpu->env, ARM_FEATURE_MPU);
590 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
591 cpu->midr = 0x41059461;
592 cpu->ctr = 0x0f004006;
593 cpu->reset_sctlr = 0x00000078;
596 static void arm1026_initfn(Object *obj)
598 ARMCPU *cpu = ARM_CPU(obj);
600 cpu->dtb_compatible = "arm,arm1026";
601 set_feature(&cpu->env, ARM_FEATURE_V5);
602 set_feature(&cpu->env, ARM_FEATURE_VFP);
603 set_feature(&cpu->env, ARM_FEATURE_AUXCR);
604 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
605 set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN);
606 cpu->midr = 0x4106a262;
607 cpu->reset_fpsid = 0x410110a0;
608 cpu->ctr = 0x1dd20d2;
609 cpu->reset_sctlr = 0x00090078;
610 cpu->reset_auxcr = 1;
612 /* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */
613 ARMCPRegInfo ifar = {
614 .name = "IFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 1,
615 .access = PL1_RW,
616 .fieldoffset = offsetof(CPUARMState, cp15.ifar_ns),
617 .resetvalue = 0
619 define_one_arm_cp_reg(cpu, &ifar);
623 static void arm1136_r2_initfn(Object *obj)
625 ARMCPU *cpu = ARM_CPU(obj);
626 /* What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an
627 * older core than plain "arm1136". In particular this does not
628 * have the v6K features.
629 * These ID register values are correct for 1136 but may be wrong
630 * for 1136_r2 (in particular r0p2 does not actually implement most
631 * of the ID registers).
634 cpu->dtb_compatible = "arm,arm1136";
635 set_feature(&cpu->env, ARM_FEATURE_V6);
636 set_feature(&cpu->env, ARM_FEATURE_VFP);
637 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
638 set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG);
639 set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS);
640 cpu->midr = 0x4107b362;
641 cpu->reset_fpsid = 0x410120b4;
642 cpu->mvfr0 = 0x11111111;
643 cpu->mvfr1 = 0x00000000;
644 cpu->ctr = 0x1dd20d2;
645 cpu->reset_sctlr = 0x00050078;
646 cpu->id_pfr0 = 0x111;
647 cpu->id_pfr1 = 0x1;
648 cpu->id_dfr0 = 0x2;
649 cpu->id_afr0 = 0x3;
650 cpu->id_mmfr0 = 0x01130003;
651 cpu->id_mmfr1 = 0x10030302;
652 cpu->id_mmfr2 = 0x01222110;
653 cpu->id_isar0 = 0x00140011;
654 cpu->id_isar1 = 0x12002111;
655 cpu->id_isar2 = 0x11231111;
656 cpu->id_isar3 = 0x01102131;
657 cpu->id_isar4 = 0x141;
658 cpu->reset_auxcr = 7;
661 static void arm1136_initfn(Object *obj)
663 ARMCPU *cpu = ARM_CPU(obj);
665 cpu->dtb_compatible = "arm,arm1136";
666 set_feature(&cpu->env, ARM_FEATURE_V6K);
667 set_feature(&cpu->env, ARM_FEATURE_V6);
668 set_feature(&cpu->env, ARM_FEATURE_VFP);
669 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
670 set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG);
671 set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS);
672 cpu->midr = 0x4117b363;
673 cpu->reset_fpsid = 0x410120b4;
674 cpu->mvfr0 = 0x11111111;
675 cpu->mvfr1 = 0x00000000;
676 cpu->ctr = 0x1dd20d2;
677 cpu->reset_sctlr = 0x00050078;
678 cpu->id_pfr0 = 0x111;
679 cpu->id_pfr1 = 0x1;
680 cpu->id_dfr0 = 0x2;
681 cpu->id_afr0 = 0x3;
682 cpu->id_mmfr0 = 0x01130003;
683 cpu->id_mmfr1 = 0x10030302;
684 cpu->id_mmfr2 = 0x01222110;
685 cpu->id_isar0 = 0x00140011;
686 cpu->id_isar1 = 0x12002111;
687 cpu->id_isar2 = 0x11231111;
688 cpu->id_isar3 = 0x01102131;
689 cpu->id_isar4 = 0x141;
690 cpu->reset_auxcr = 7;
693 static void arm1176_initfn(Object *obj)
695 ARMCPU *cpu = ARM_CPU(obj);
697 cpu->dtb_compatible = "arm,arm1176";
698 set_feature(&cpu->env, ARM_FEATURE_V6K);
699 set_feature(&cpu->env, ARM_FEATURE_VFP);
700 set_feature(&cpu->env, ARM_FEATURE_VAPA);
701 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
702 set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG);
703 set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS);
704 set_feature(&cpu->env, ARM_FEATURE_EL3);
705 cpu->midr = 0x410fb767;
706 cpu->reset_fpsid = 0x410120b5;
707 cpu->mvfr0 = 0x11111111;
708 cpu->mvfr1 = 0x00000000;
709 cpu->ctr = 0x1dd20d2;
710 cpu->reset_sctlr = 0x00050078;
711 cpu->id_pfr0 = 0x111;
712 cpu->id_pfr1 = 0x11;
713 cpu->id_dfr0 = 0x33;
714 cpu->id_afr0 = 0;
715 cpu->id_mmfr0 = 0x01130003;
716 cpu->id_mmfr1 = 0x10030302;
717 cpu->id_mmfr2 = 0x01222100;
718 cpu->id_isar0 = 0x0140011;
719 cpu->id_isar1 = 0x12002111;
720 cpu->id_isar2 = 0x11231121;
721 cpu->id_isar3 = 0x01102131;
722 cpu->id_isar4 = 0x01141;
723 cpu->reset_auxcr = 7;
726 static void arm11mpcore_initfn(Object *obj)
728 ARMCPU *cpu = ARM_CPU(obj);
730 cpu->dtb_compatible = "arm,arm11mpcore";
731 set_feature(&cpu->env, ARM_FEATURE_V6K);
732 set_feature(&cpu->env, ARM_FEATURE_VFP);
733 set_feature(&cpu->env, ARM_FEATURE_VAPA);
734 set_feature(&cpu->env, ARM_FEATURE_MPIDR);
735 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
736 cpu->midr = 0x410fb022;
737 cpu->reset_fpsid = 0x410120b4;
738 cpu->mvfr0 = 0x11111111;
739 cpu->mvfr1 = 0x00000000;
740 cpu->ctr = 0x1d192992; /* 32K icache 32K dcache */
741 cpu->id_pfr0 = 0x111;
742 cpu->id_pfr1 = 0x1;
743 cpu->id_dfr0 = 0;
744 cpu->id_afr0 = 0x2;
745 cpu->id_mmfr0 = 0x01100103;
746 cpu->id_mmfr1 = 0x10020302;
747 cpu->id_mmfr2 = 0x01222000;
748 cpu->id_isar0 = 0x00100011;
749 cpu->id_isar1 = 0x12002111;
750 cpu->id_isar2 = 0x11221011;
751 cpu->id_isar3 = 0x01102131;
752 cpu->id_isar4 = 0x141;
753 cpu->reset_auxcr = 1;
756 static void cortex_m3_initfn(Object *obj)
758 ARMCPU *cpu = ARM_CPU(obj);
759 set_feature(&cpu->env, ARM_FEATURE_V7);
760 set_feature(&cpu->env, ARM_FEATURE_M);
761 cpu->midr = 0x410fc231;
764 static void arm_v7m_class_init(ObjectClass *oc, void *data)
766 CPUClass *cc = CPU_CLASS(oc);
768 #ifndef CONFIG_USER_ONLY
769 cc->do_interrupt = arm_v7m_cpu_do_interrupt;
770 #endif
772 cc->cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt;
775 static const ARMCPRegInfo cortexa8_cp_reginfo[] = {
776 { .name = "L2LOCKDOWN", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 0,
777 .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
778 { .name = "L2AUXCR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2,
779 .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
780 REGINFO_SENTINEL
783 static void cortex_a8_initfn(Object *obj)
785 ARMCPU *cpu = ARM_CPU(obj);
787 cpu->dtb_compatible = "arm,cortex-a8";
788 set_feature(&cpu->env, ARM_FEATURE_V7);
789 set_feature(&cpu->env, ARM_FEATURE_VFP3);
790 set_feature(&cpu->env, ARM_FEATURE_NEON);
791 set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
792 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
793 set_feature(&cpu->env, ARM_FEATURE_EL3);
794 cpu->midr = 0x410fc080;
795 cpu->reset_fpsid = 0x410330c0;
796 cpu->mvfr0 = 0x11110222;
797 cpu->mvfr1 = 0x00011100;
798 cpu->ctr = 0x82048004;
799 cpu->reset_sctlr = 0x00c50078;
800 cpu->id_pfr0 = 0x1031;
801 cpu->id_pfr1 = 0x11;
802 cpu->id_dfr0 = 0x400;
803 cpu->id_afr0 = 0;
804 cpu->id_mmfr0 = 0x31100003;
805 cpu->id_mmfr1 = 0x20000000;
806 cpu->id_mmfr2 = 0x01202000;
807 cpu->id_mmfr3 = 0x11;
808 cpu->id_isar0 = 0x00101111;
809 cpu->id_isar1 = 0x12112111;
810 cpu->id_isar2 = 0x21232031;
811 cpu->id_isar3 = 0x11112131;
812 cpu->id_isar4 = 0x00111142;
813 cpu->dbgdidr = 0x15141000;
814 cpu->clidr = (1 << 27) | (2 << 24) | 3;
815 cpu->ccsidr[0] = 0xe007e01a; /* 16k L1 dcache. */
816 cpu->ccsidr[1] = 0x2007e01a; /* 16k L1 icache. */
817 cpu->ccsidr[2] = 0xf0000000; /* No L2 icache. */
818 cpu->reset_auxcr = 2;
819 define_arm_cp_regs(cpu, cortexa8_cp_reginfo);
822 static const ARMCPRegInfo cortexa9_cp_reginfo[] = {
823 /* power_control should be set to maximum latency. Again,
824 * default to 0 and set by private hook
826 { .name = "A9_PWRCTL", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 0,
827 .access = PL1_RW, .resetvalue = 0,
828 .fieldoffset = offsetof(CPUARMState, cp15.c15_power_control) },
829 { .name = "A9_DIAG", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 1,
830 .access = PL1_RW, .resetvalue = 0,
831 .fieldoffset = offsetof(CPUARMState, cp15.c15_diagnostic) },
832 { .name = "A9_PWRDIAG", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 2,
833 .access = PL1_RW, .resetvalue = 0,
834 .fieldoffset = offsetof(CPUARMState, cp15.c15_power_diagnostic) },
835 { .name = "NEONBUSY", .cp = 15, .crn = 15, .crm = 1, .opc1 = 0, .opc2 = 0,
836 .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
837 /* TLB lockdown control */
838 { .name = "TLB_LOCKR", .cp = 15, .crn = 15, .crm = 4, .opc1 = 5, .opc2 = 2,
839 .access = PL1_W, .resetvalue = 0, .type = ARM_CP_NOP },
840 { .name = "TLB_LOCKW", .cp = 15, .crn = 15, .crm = 4, .opc1 = 5, .opc2 = 4,
841 .access = PL1_W, .resetvalue = 0, .type = ARM_CP_NOP },
842 { .name = "TLB_VA", .cp = 15, .crn = 15, .crm = 5, .opc1 = 5, .opc2 = 2,
843 .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
844 { .name = "TLB_PA", .cp = 15, .crn = 15, .crm = 6, .opc1 = 5, .opc2 = 2,
845 .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
846 { .name = "TLB_ATTR", .cp = 15, .crn = 15, .crm = 7, .opc1 = 5, .opc2 = 2,
847 .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
848 REGINFO_SENTINEL
851 static void cortex_a9_initfn(Object *obj)
853 ARMCPU *cpu = ARM_CPU(obj);
855 cpu->dtb_compatible = "arm,cortex-a9";
856 set_feature(&cpu->env, ARM_FEATURE_V7);
857 set_feature(&cpu->env, ARM_FEATURE_VFP3);
858 set_feature(&cpu->env, ARM_FEATURE_VFP_FP16);
859 set_feature(&cpu->env, ARM_FEATURE_NEON);
860 set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
861 set_feature(&cpu->env, ARM_FEATURE_EL3);
862 /* Note that A9 supports the MP extensions even for
863 * A9UP and single-core A9MP (which are both different
864 * and valid configurations; we don't model A9UP).
866 set_feature(&cpu->env, ARM_FEATURE_V7MP);
867 set_feature(&cpu->env, ARM_FEATURE_CBAR);
868 cpu->midr = 0x410fc090;
869 cpu->reset_fpsid = 0x41033090;
870 cpu->mvfr0 = 0x11110222;
871 cpu->mvfr1 = 0x01111111;
872 cpu->ctr = 0x80038003;
873 cpu->reset_sctlr = 0x00c50078;
874 cpu->id_pfr0 = 0x1031;
875 cpu->id_pfr1 = 0x11;
876 cpu->id_dfr0 = 0x000;
877 cpu->id_afr0 = 0;
878 cpu->id_mmfr0 = 0x00100103;
879 cpu->id_mmfr1 = 0x20000000;
880 cpu->id_mmfr2 = 0x01230000;
881 cpu->id_mmfr3 = 0x00002111;
882 cpu->id_isar0 = 0x00101111;
883 cpu->id_isar1 = 0x13112111;
884 cpu->id_isar2 = 0x21232041;
885 cpu->id_isar3 = 0x11112131;
886 cpu->id_isar4 = 0x00111142;
887 cpu->dbgdidr = 0x35141000;
888 cpu->clidr = (1 << 27) | (1 << 24) | 3;
889 cpu->ccsidr[0] = 0xe00fe019; /* 16k L1 dcache. */
890 cpu->ccsidr[1] = 0x200fe019; /* 16k L1 icache. */
891 define_arm_cp_regs(cpu, cortexa9_cp_reginfo);
894 #ifndef CONFIG_USER_ONLY
895 static uint64_t a15_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
897 /* Linux wants the number of processors from here.
898 * Might as well set the interrupt-controller bit too.
900 return ((smp_cpus - 1) << 24) | (1 << 23);
902 #endif
904 static const ARMCPRegInfo cortexa15_cp_reginfo[] = {
905 #ifndef CONFIG_USER_ONLY
906 { .name = "L2CTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2,
907 .access = PL1_RW, .resetvalue = 0, .readfn = a15_l2ctlr_read,
908 .writefn = arm_cp_write_ignore, },
909 #endif
910 { .name = "L2ECTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 3,
911 .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
912 REGINFO_SENTINEL
915 static void cortex_a15_initfn(Object *obj)
917 ARMCPU *cpu = ARM_CPU(obj);
919 cpu->dtb_compatible = "arm,cortex-a15";
920 set_feature(&cpu->env, ARM_FEATURE_V7);
921 set_feature(&cpu->env, ARM_FEATURE_VFP4);
922 set_feature(&cpu->env, ARM_FEATURE_NEON);
923 set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
924 set_feature(&cpu->env, ARM_FEATURE_ARM_DIV);
925 set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
926 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
927 set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
928 set_feature(&cpu->env, ARM_FEATURE_LPAE);
929 set_feature(&cpu->env, ARM_FEATURE_EL3);
930 cpu->kvm_target = QEMU_KVM_ARM_TARGET_CORTEX_A15;
931 cpu->midr = 0x412fc0f1;
932 cpu->reset_fpsid = 0x410430f0;
933 cpu->mvfr0 = 0x10110222;
934 cpu->mvfr1 = 0x11111111;
935 cpu->ctr = 0x8444c004;
936 cpu->reset_sctlr = 0x00c50078;
937 cpu->id_pfr0 = 0x00001131;
938 cpu->id_pfr1 = 0x00011011;
939 cpu->id_dfr0 = 0x02010555;
940 cpu->id_afr0 = 0x00000000;
941 cpu->id_mmfr0 = 0x10201105;
942 cpu->id_mmfr1 = 0x20000000;
943 cpu->id_mmfr2 = 0x01240000;
944 cpu->id_mmfr3 = 0x02102211;
945 cpu->id_isar0 = 0x02101110;
946 cpu->id_isar1 = 0x13112111;
947 cpu->id_isar2 = 0x21232041;
948 cpu->id_isar3 = 0x11112131;
949 cpu->id_isar4 = 0x10011142;
950 cpu->dbgdidr = 0x3515f021;
951 cpu->clidr = 0x0a200023;
952 cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */
953 cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */
954 cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
955 define_arm_cp_regs(cpu, cortexa15_cp_reginfo);
958 static void ti925t_initfn(Object *obj)
960 ARMCPU *cpu = ARM_CPU(obj);
961 set_feature(&cpu->env, ARM_FEATURE_V4T);
962 set_feature(&cpu->env, ARM_FEATURE_OMAPCP);
963 cpu->midr = ARM_CPUID_TI925T;
964 cpu->ctr = 0x5109149;
965 cpu->reset_sctlr = 0x00000070;
968 static void sa1100_initfn(Object *obj)
970 ARMCPU *cpu = ARM_CPU(obj);
972 cpu->dtb_compatible = "intel,sa1100";
973 set_feature(&cpu->env, ARM_FEATURE_STRONGARM);
974 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
975 cpu->midr = 0x4401A11B;
976 cpu->reset_sctlr = 0x00000070;
979 static void sa1110_initfn(Object *obj)
981 ARMCPU *cpu = ARM_CPU(obj);
982 set_feature(&cpu->env, ARM_FEATURE_STRONGARM);
983 set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
984 cpu->midr = 0x6901B119;
985 cpu->reset_sctlr = 0x00000070;
988 static void pxa250_initfn(Object *obj)
990 ARMCPU *cpu = ARM_CPU(obj);
992 cpu->dtb_compatible = "marvell,xscale";
993 set_feature(&cpu->env, ARM_FEATURE_V5);
994 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
995 cpu->midr = 0x69052100;
996 cpu->ctr = 0xd172172;
997 cpu->reset_sctlr = 0x00000078;
1000 static void pxa255_initfn(Object *obj)
1002 ARMCPU *cpu = ARM_CPU(obj);
1004 cpu->dtb_compatible = "marvell,xscale";
1005 set_feature(&cpu->env, ARM_FEATURE_V5);
1006 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1007 cpu->midr = 0x69052d00;
1008 cpu->ctr = 0xd172172;
1009 cpu->reset_sctlr = 0x00000078;
1012 static void pxa260_initfn(Object *obj)
1014 ARMCPU *cpu = ARM_CPU(obj);
1016 cpu->dtb_compatible = "marvell,xscale";
1017 set_feature(&cpu->env, ARM_FEATURE_V5);
1018 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1019 cpu->midr = 0x69052903;
1020 cpu->ctr = 0xd172172;
1021 cpu->reset_sctlr = 0x00000078;
1024 static void pxa261_initfn(Object *obj)
1026 ARMCPU *cpu = ARM_CPU(obj);
1028 cpu->dtb_compatible = "marvell,xscale";
1029 set_feature(&cpu->env, ARM_FEATURE_V5);
1030 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1031 cpu->midr = 0x69052d05;
1032 cpu->ctr = 0xd172172;
1033 cpu->reset_sctlr = 0x00000078;
1036 static void pxa262_initfn(Object *obj)
1038 ARMCPU *cpu = ARM_CPU(obj);
1040 cpu->dtb_compatible = "marvell,xscale";
1041 set_feature(&cpu->env, ARM_FEATURE_V5);
1042 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1043 cpu->midr = 0x69052d06;
1044 cpu->ctr = 0xd172172;
1045 cpu->reset_sctlr = 0x00000078;
1048 static void pxa270a0_initfn(Object *obj)
1050 ARMCPU *cpu = ARM_CPU(obj);
1052 cpu->dtb_compatible = "marvell,xscale";
1053 set_feature(&cpu->env, ARM_FEATURE_V5);
1054 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1055 set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
1056 cpu->midr = 0x69054110;
1057 cpu->ctr = 0xd172172;
1058 cpu->reset_sctlr = 0x00000078;
1061 static void pxa270a1_initfn(Object *obj)
1063 ARMCPU *cpu = ARM_CPU(obj);
1065 cpu->dtb_compatible = "marvell,xscale";
1066 set_feature(&cpu->env, ARM_FEATURE_V5);
1067 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1068 set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
1069 cpu->midr = 0x69054111;
1070 cpu->ctr = 0xd172172;
1071 cpu->reset_sctlr = 0x00000078;
1074 static void pxa270b0_initfn(Object *obj)
1076 ARMCPU *cpu = ARM_CPU(obj);
1078 cpu->dtb_compatible = "marvell,xscale";
1079 set_feature(&cpu->env, ARM_FEATURE_V5);
1080 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1081 set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
1082 cpu->midr = 0x69054112;
1083 cpu->ctr = 0xd172172;
1084 cpu->reset_sctlr = 0x00000078;
1087 static void pxa270b1_initfn(Object *obj)
1089 ARMCPU *cpu = ARM_CPU(obj);
1091 cpu->dtb_compatible = "marvell,xscale";
1092 set_feature(&cpu->env, ARM_FEATURE_V5);
1093 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1094 set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
1095 cpu->midr = 0x69054113;
1096 cpu->ctr = 0xd172172;
1097 cpu->reset_sctlr = 0x00000078;
1100 static void pxa270c0_initfn(Object *obj)
1102 ARMCPU *cpu = ARM_CPU(obj);
1104 cpu->dtb_compatible = "marvell,xscale";
1105 set_feature(&cpu->env, ARM_FEATURE_V5);
1106 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1107 set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
1108 cpu->midr = 0x69054114;
1109 cpu->ctr = 0xd172172;
1110 cpu->reset_sctlr = 0x00000078;
1113 static void pxa270c5_initfn(Object *obj)
1115 ARMCPU *cpu = ARM_CPU(obj);
1117 cpu->dtb_compatible = "marvell,xscale";
1118 set_feature(&cpu->env, ARM_FEATURE_V5);
1119 set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1120 set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
1121 cpu->midr = 0x69054117;
1122 cpu->ctr = 0xd172172;
1123 cpu->reset_sctlr = 0x00000078;
1126 #ifdef CONFIG_USER_ONLY
1127 static void arm_any_initfn(Object *obj)
1129 ARMCPU *cpu = ARM_CPU(obj);
1130 set_feature(&cpu->env, ARM_FEATURE_V8);
1131 set_feature(&cpu->env, ARM_FEATURE_VFP4);
1132 set_feature(&cpu->env, ARM_FEATURE_NEON);
1133 set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
1134 set_feature(&cpu->env, ARM_FEATURE_V8_AES);
1135 set_feature(&cpu->env, ARM_FEATURE_V8_SHA1);
1136 set_feature(&cpu->env, ARM_FEATURE_V8_SHA256);
1137 set_feature(&cpu->env, ARM_FEATURE_V8_PMULL);
1138 set_feature(&cpu->env, ARM_FEATURE_CRC);
1139 cpu->midr = 0xffffffff;
1141 #endif
1143 #endif /* !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) */
1145 typedef struct ARMCPUInfo {
1146 const char *name;
1147 void (*initfn)(Object *obj);
1148 void (*class_init)(ObjectClass *oc, void *data);
1149 } ARMCPUInfo;
1151 static const ARMCPUInfo arm_cpus[] = {
1152 #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
1153 { .name = "arm926", .initfn = arm926_initfn },
1154 { .name = "arm946", .initfn = arm946_initfn },
1155 { .name = "arm1026", .initfn = arm1026_initfn },
1156 /* What QEMU calls "arm1136-r2" is actually the 1136 r0p2, i.e. an
1157 * older core than plain "arm1136". In particular this does not
1158 * have the v6K features.
1160 { .name = "arm1136-r2", .initfn = arm1136_r2_initfn },
1161 { .name = "arm1136", .initfn = arm1136_initfn },
1162 { .name = "arm1176", .initfn = arm1176_initfn },
1163 { .name = "arm11mpcore", .initfn = arm11mpcore_initfn },
1164 { .name = "cortex-m3", .initfn = cortex_m3_initfn,
1165 .class_init = arm_v7m_class_init },
1166 { .name = "cortex-a8", .initfn = cortex_a8_initfn },
1167 { .name = "cortex-a9", .initfn = cortex_a9_initfn },
1168 { .name = "cortex-a15", .initfn = cortex_a15_initfn },
1169 { .name = "ti925t", .initfn = ti925t_initfn },
1170 { .name = "sa1100", .initfn = sa1100_initfn },
1171 { .name = "sa1110", .initfn = sa1110_initfn },
1172 { .name = "pxa250", .initfn = pxa250_initfn },
1173 { .name = "pxa255", .initfn = pxa255_initfn },
1174 { .name = "pxa260", .initfn = pxa260_initfn },
1175 { .name = "pxa261", .initfn = pxa261_initfn },
1176 { .name = "pxa262", .initfn = pxa262_initfn },
1177 /* "pxa270" is an alias for "pxa270-a0" */
1178 { .name = "pxa270", .initfn = pxa270a0_initfn },
1179 { .name = "pxa270-a0", .initfn = pxa270a0_initfn },
1180 { .name = "pxa270-a1", .initfn = pxa270a1_initfn },
1181 { .name = "pxa270-b0", .initfn = pxa270b0_initfn },
1182 { .name = "pxa270-b1", .initfn = pxa270b1_initfn },
1183 { .name = "pxa270-c0", .initfn = pxa270c0_initfn },
1184 { .name = "pxa270-c5", .initfn = pxa270c5_initfn },
1185 #ifdef CONFIG_USER_ONLY
1186 { .name = "any", .initfn = arm_any_initfn },
1187 #endif
1188 #endif
1189 { .name = NULL }
1192 static Property arm_cpu_properties[] = {
1193 DEFINE_PROP_BOOL("start-powered-off", ARMCPU, start_powered_off, false),
1194 DEFINE_PROP_UINT32("psci-conduit", ARMCPU, psci_conduit, 0),
1195 DEFINE_PROP_UINT32("midr", ARMCPU, midr, 0),
1196 DEFINE_PROP_END_OF_LIST()
1199 static void arm_cpu_class_init(ObjectClass *oc, void *data)
1201 ARMCPUClass *acc = ARM_CPU_CLASS(oc);
1202 CPUClass *cc = CPU_CLASS(acc);
1203 DeviceClass *dc = DEVICE_CLASS(oc);
1205 acc->parent_realize = dc->realize;
1206 dc->realize = arm_cpu_realizefn;
1207 dc->props = arm_cpu_properties;
1209 acc->parent_reset = cc->reset;
1210 cc->reset = arm_cpu_reset;
1212 cc->class_by_name = arm_cpu_class_by_name;
1213 cc->has_work = arm_cpu_has_work;
1214 cc->cpu_exec_interrupt = arm_cpu_exec_interrupt;
1215 cc->dump_state = arm_cpu_dump_state;
1216 cc->set_pc = arm_cpu_set_pc;
1217 cc->gdb_read_register = arm_cpu_gdb_read_register;
1218 cc->gdb_write_register = arm_cpu_gdb_write_register;
1219 #ifdef CONFIG_USER_ONLY
1220 cc->handle_mmu_fault = arm_cpu_handle_mmu_fault;
1221 #else
1222 cc->do_interrupt = arm_cpu_do_interrupt;
1223 cc->get_phys_page_debug = arm_cpu_get_phys_page_debug;
1224 cc->vmsd = &vmstate_arm_cpu;
1225 cc->virtio_is_big_endian = arm_cpu_is_big_endian;
1226 #endif
1227 cc->gdb_num_core_regs = 26;
1228 cc->gdb_core_xml_file = "arm-core.xml";
1229 cc->gdb_stop_before_watchpoint = true;
1230 cc->debug_excp_handler = arm_debug_excp_handler;
1233 static void cpu_register(const ARMCPUInfo *info)
1235 TypeInfo type_info = {
1236 .parent = TYPE_ARM_CPU,
1237 .instance_size = sizeof(ARMCPU),
1238 .instance_init = info->initfn,
1239 .class_size = sizeof(ARMCPUClass),
1240 .class_init = info->class_init,
1243 type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);
1244 type_register(&type_info);
1245 g_free((void *)type_info.name);
1248 static const TypeInfo arm_cpu_type_info = {
1249 .name = TYPE_ARM_CPU,
1250 .parent = TYPE_CPU,
1251 .instance_size = sizeof(ARMCPU),
1252 .instance_init = arm_cpu_initfn,
1253 .instance_post_init = arm_cpu_post_init,
1254 .instance_finalize = arm_cpu_finalizefn,
1255 .abstract = true,
1256 .class_size = sizeof(ARMCPUClass),
1257 .class_init = arm_cpu_class_init,
1260 static void arm_cpu_register_types(void)
1262 const ARMCPUInfo *info = arm_cpus;
1264 type_register_static(&arm_cpu_type_info);
1266 while (info->name) {
1267 cpu_register(info);
1268 info++;
1272 type_init(arm_cpu_register_types)