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 "qemu/osdep.h"
22 #include "target/arm/idau.h"
23 #include "qemu/error-report.h"
24 #include "qapi/error.h"
26 #include "internals.h"
27 #include "qemu-common.h"
28 #include "exec/exec-all.h"
29 #include "hw/qdev-properties.h"
30 #if !defined(CONFIG_USER_ONLY)
31 #include "hw/loader.h"
33 #include "hw/arm/arm.h"
34 #include "sysemu/sysemu.h"
35 #include "sysemu/hw_accel.h"
37 #include "disas/capstone.h"
38 #include "fpu/softfloat.h"
40 static void arm_cpu_set_pc(CPUState
*cs
, vaddr value
)
42 ARMCPU
*cpu
= ARM_CPU(cs
);
44 cpu
->env
.regs
[15] = value
;
47 static bool arm_cpu_has_work(CPUState
*cs
)
49 ARMCPU
*cpu
= ARM_CPU(cs
);
51 return (cpu
->power_state
!= PSCI_OFF
)
52 && cs
->interrupt_request
&
53 (CPU_INTERRUPT_FIQ
| CPU_INTERRUPT_HARD
54 | CPU_INTERRUPT_VFIQ
| CPU_INTERRUPT_VIRQ
55 | CPU_INTERRUPT_EXITTB
);
58 void arm_register_pre_el_change_hook(ARMCPU
*cpu
, ARMELChangeHookFn
*hook
,
61 ARMELChangeHook
*entry
= g_new0(ARMELChangeHook
, 1);
64 entry
->opaque
= opaque
;
66 QLIST_INSERT_HEAD(&cpu
->pre_el_change_hooks
, entry
, node
);
69 void arm_register_el_change_hook(ARMCPU
*cpu
, ARMELChangeHookFn
*hook
,
72 ARMELChangeHook
*entry
= g_new0(ARMELChangeHook
, 1);
75 entry
->opaque
= opaque
;
77 QLIST_INSERT_HEAD(&cpu
->el_change_hooks
, entry
, node
);
80 static void cp_reg_reset(gpointer key
, gpointer value
, gpointer opaque
)
82 /* Reset a single ARMCPRegInfo register */
83 ARMCPRegInfo
*ri
= value
;
86 if (ri
->type
& (ARM_CP_SPECIAL
| ARM_CP_ALIAS
)) {
91 ri
->resetfn(&cpu
->env
, ri
);
95 /* A zero offset is never possible as it would be regs[0]
96 * so we use it to indicate that reset is being handled elsewhere.
97 * This is basically only used for fields in non-core coprocessors
98 * (like the pxa2xx ones).
100 if (!ri
->fieldoffset
) {
104 if (cpreg_field_is_64bit(ri
)) {
105 CPREG_FIELD64(&cpu
->env
, ri
) = ri
->resetvalue
;
107 CPREG_FIELD32(&cpu
->env
, ri
) = ri
->resetvalue
;
111 static void cp_reg_check_reset(gpointer key
, gpointer value
, gpointer opaque
)
113 /* Purely an assertion check: we've already done reset once,
114 * so now check that running the reset for the cpreg doesn't
115 * change its value. This traps bugs where two different cpregs
116 * both try to reset the same state field but to different values.
118 ARMCPRegInfo
*ri
= value
;
119 ARMCPU
*cpu
= opaque
;
120 uint64_t oldvalue
, newvalue
;
122 if (ri
->type
& (ARM_CP_SPECIAL
| ARM_CP_ALIAS
| ARM_CP_NO_RAW
)) {
126 oldvalue
= read_raw_cp_reg(&cpu
->env
, ri
);
127 cp_reg_reset(key
, value
, opaque
);
128 newvalue
= read_raw_cp_reg(&cpu
->env
, ri
);
129 assert(oldvalue
== newvalue
);
132 /* CPUClass::reset() */
133 static void arm_cpu_reset(CPUState
*s
)
135 ARMCPU
*cpu
= ARM_CPU(s
);
136 ARMCPUClass
*acc
= ARM_CPU_GET_CLASS(cpu
);
137 CPUARMState
*env
= &cpu
->env
;
139 acc
->parent_reset(s
);
141 memset(env
, 0, offsetof(CPUARMState
, end_reset_fields
));
143 g_hash_table_foreach(cpu
->cp_regs
, cp_reg_reset
, cpu
);
144 g_hash_table_foreach(cpu
->cp_regs
, cp_reg_check_reset
, cpu
);
146 env
->vfp
.xregs
[ARM_VFP_FPSID
] = cpu
->reset_fpsid
;
147 env
->vfp
.xregs
[ARM_VFP_MVFR0
] = cpu
->isar
.mvfr0
;
148 env
->vfp
.xregs
[ARM_VFP_MVFR1
] = cpu
->isar
.mvfr1
;
149 env
->vfp
.xregs
[ARM_VFP_MVFR2
] = cpu
->isar
.mvfr2
;
151 cpu
->power_state
= cpu
->start_powered_off
? PSCI_OFF
: PSCI_ON
;
152 s
->halted
= cpu
->start_powered_off
;
154 if (arm_feature(env
, ARM_FEATURE_IWMMXT
)) {
155 env
->iwmmxt
.cregs
[ARM_IWMMXT_wCID
] = 0x69051000 | 'Q';
158 if (arm_feature(env
, ARM_FEATURE_AARCH64
)) {
159 /* 64 bit CPUs always start in 64 bit mode */
161 #if defined(CONFIG_USER_ONLY)
162 env
->pstate
= PSTATE_MODE_EL0t
;
163 /* Userspace expects access to DC ZVA, CTL_EL0 and the cache ops */
164 env
->cp15
.sctlr_el
[1] |= SCTLR_UCT
| SCTLR_UCI
| SCTLR_DZE
;
165 /* Enable all PAC instructions */
166 env
->cp15
.hcr_el2
|= HCR_API
;
167 env
->cp15
.scr_el3
|= SCR_API
;
168 /* and to the FP/Neon instructions */
169 env
->cp15
.cpacr_el1
= deposit64(env
->cp15
.cpacr_el1
, 20, 2, 3);
170 /* and to the SVE instructions */
171 env
->cp15
.cpacr_el1
= deposit64(env
->cp15
.cpacr_el1
, 16, 2, 3);
172 env
->cp15
.cptr_el
[3] |= CPTR_EZ
;
173 /* with maximum vector length */
174 env
->vfp
.zcr_el
[1] = cpu
->sve_max_vq
- 1;
175 env
->vfp
.zcr_el
[2] = env
->vfp
.zcr_el
[1];
176 env
->vfp
.zcr_el
[3] = env
->vfp
.zcr_el
[1];
178 /* Reset into the highest available EL */
179 if (arm_feature(env
, ARM_FEATURE_EL3
)) {
180 env
->pstate
= PSTATE_MODE_EL3h
;
181 } else if (arm_feature(env
, ARM_FEATURE_EL2
)) {
182 env
->pstate
= PSTATE_MODE_EL2h
;
184 env
->pstate
= PSTATE_MODE_EL1h
;
186 env
->pc
= cpu
->rvbar
;
189 #if defined(CONFIG_USER_ONLY)
190 /* Userspace expects access to cp10 and cp11 for FP/Neon */
191 env
->cp15
.cpacr_el1
= deposit64(env
->cp15
.cpacr_el1
, 20, 4, 0xf);
195 #if defined(CONFIG_USER_ONLY)
196 env
->uncached_cpsr
= ARM_CPU_MODE_USR
;
197 /* For user mode we must enable access to coprocessors */
198 env
->vfp
.xregs
[ARM_VFP_FPEXC
] = 1 << 30;
199 if (arm_feature(env
, ARM_FEATURE_IWMMXT
)) {
200 env
->cp15
.c15_cpar
= 3;
201 } else if (arm_feature(env
, ARM_FEATURE_XSCALE
)) {
202 env
->cp15
.c15_cpar
= 1;
207 * If the highest available EL is EL2, AArch32 will start in Hyp
208 * mode; otherwise it starts in SVC. Note that if we start in
209 * AArch64 then these values in the uncached_cpsr will be ignored.
211 if (arm_feature(env
, ARM_FEATURE_EL2
) &&
212 !arm_feature(env
, ARM_FEATURE_EL3
)) {
213 env
->uncached_cpsr
= ARM_CPU_MODE_HYP
;
215 env
->uncached_cpsr
= ARM_CPU_MODE_SVC
;
217 env
->daif
= PSTATE_D
| PSTATE_A
| PSTATE_I
| PSTATE_F
;
219 if (arm_feature(env
, ARM_FEATURE_M
)) {
220 uint32_t initial_msp
; /* Loaded from 0x0 */
221 uint32_t initial_pc
; /* Loaded from 0x4 */
225 if (arm_feature(env
, ARM_FEATURE_M_SECURITY
)) {
226 env
->v7m
.secure
= true;
228 /* This bit resets to 0 if security is supported, but 1 if
229 * it is not. The bit is not present in v7M, but we set it
230 * here so we can avoid having to make checks on it conditional
231 * on ARM_FEATURE_V8 (we don't let the guest see the bit).
233 env
->v7m
.aircr
= R_V7M_AIRCR_BFHFNMINS_MASK
;
236 /* In v7M the reset value of this bit is IMPDEF, but ARM recommends
237 * that it resets to 1, so QEMU always does that rather than making
238 * it dependent on CPU model. In v8M it is RES1.
240 env
->v7m
.ccr
[M_REG_NS
] = R_V7M_CCR_STKALIGN_MASK
;
241 env
->v7m
.ccr
[M_REG_S
] = R_V7M_CCR_STKALIGN_MASK
;
242 if (arm_feature(env
, ARM_FEATURE_V8
)) {
243 /* in v8M the NONBASETHRDENA bit [0] is RES1 */
244 env
->v7m
.ccr
[M_REG_NS
] |= R_V7M_CCR_NONBASETHRDENA_MASK
;
245 env
->v7m
.ccr
[M_REG_S
] |= R_V7M_CCR_NONBASETHRDENA_MASK
;
247 if (!arm_feature(env
, ARM_FEATURE_M_MAIN
)) {
248 env
->v7m
.ccr
[M_REG_NS
] |= R_V7M_CCR_UNALIGN_TRP_MASK
;
249 env
->v7m
.ccr
[M_REG_S
] |= R_V7M_CCR_UNALIGN_TRP_MASK
;
252 /* Unlike A/R profile, M profile defines the reset LR value */
253 env
->regs
[14] = 0xffffffff;
255 env
->v7m
.vecbase
[M_REG_S
] = cpu
->init_svtor
& 0xffffff80;
257 /* Load the initial SP and PC from offset 0 and 4 in the vector table */
258 vecbase
= env
->v7m
.vecbase
[env
->v7m
.secure
];
259 rom
= rom_ptr(vecbase
, 8);
261 /* Address zero is covered by ROM which hasn't yet been
262 * copied into physical memory.
264 initial_msp
= ldl_p(rom
);
265 initial_pc
= ldl_p(rom
+ 4);
267 /* Address zero not covered by a ROM blob, or the ROM blob
268 * is in non-modifiable memory and this is a second reset after
269 * it got copied into memory. In the latter case, rom_ptr
270 * will return a NULL pointer and we should use ldl_phys instead.
272 initial_msp
= ldl_phys(s
->as
, vecbase
);
273 initial_pc
= ldl_phys(s
->as
, vecbase
+ 4);
276 env
->regs
[13] = initial_msp
& 0xFFFFFFFC;
277 env
->regs
[15] = initial_pc
& ~1;
278 env
->thumb
= initial_pc
& 1;
281 /* AArch32 has a hard highvec setting of 0xFFFF0000. If we are currently
282 * executing as AArch32 then check if highvecs are enabled and
283 * adjust the PC accordingly.
285 if (A32_BANKED_CURRENT_REG_GET(env
, sctlr
) & SCTLR_V
) {
286 env
->regs
[15] = 0xFFFF0000;
289 /* M profile requires that reset clears the exclusive monitor;
290 * A profile does not, but clearing it makes more sense than having it
291 * set with an exclusive access on address zero.
293 arm_clear_exclusive(env
);
295 env
->vfp
.xregs
[ARM_VFP_FPEXC
] = 0;
298 if (arm_feature(env
, ARM_FEATURE_PMSA
)) {
299 if (cpu
->pmsav7_dregion
> 0) {
300 if (arm_feature(env
, ARM_FEATURE_V8
)) {
301 memset(env
->pmsav8
.rbar
[M_REG_NS
], 0,
302 sizeof(*env
->pmsav8
.rbar
[M_REG_NS
])
303 * cpu
->pmsav7_dregion
);
304 memset(env
->pmsav8
.rlar
[M_REG_NS
], 0,
305 sizeof(*env
->pmsav8
.rlar
[M_REG_NS
])
306 * cpu
->pmsav7_dregion
);
307 if (arm_feature(env
, ARM_FEATURE_M_SECURITY
)) {
308 memset(env
->pmsav8
.rbar
[M_REG_S
], 0,
309 sizeof(*env
->pmsav8
.rbar
[M_REG_S
])
310 * cpu
->pmsav7_dregion
);
311 memset(env
->pmsav8
.rlar
[M_REG_S
], 0,
312 sizeof(*env
->pmsav8
.rlar
[M_REG_S
])
313 * cpu
->pmsav7_dregion
);
315 } else if (arm_feature(env
, ARM_FEATURE_V7
)) {
316 memset(env
->pmsav7
.drbar
, 0,
317 sizeof(*env
->pmsav7
.drbar
) * cpu
->pmsav7_dregion
);
318 memset(env
->pmsav7
.drsr
, 0,
319 sizeof(*env
->pmsav7
.drsr
) * cpu
->pmsav7_dregion
);
320 memset(env
->pmsav7
.dracr
, 0,
321 sizeof(*env
->pmsav7
.dracr
) * cpu
->pmsav7_dregion
);
324 env
->pmsav7
.rnr
[M_REG_NS
] = 0;
325 env
->pmsav7
.rnr
[M_REG_S
] = 0;
326 env
->pmsav8
.mair0
[M_REG_NS
] = 0;
327 env
->pmsav8
.mair0
[M_REG_S
] = 0;
328 env
->pmsav8
.mair1
[M_REG_NS
] = 0;
329 env
->pmsav8
.mair1
[M_REG_S
] = 0;
332 if (arm_feature(env
, ARM_FEATURE_M_SECURITY
)) {
333 if (cpu
->sau_sregion
> 0) {
334 memset(env
->sau
.rbar
, 0, sizeof(*env
->sau
.rbar
) * cpu
->sau_sregion
);
335 memset(env
->sau
.rlar
, 0, sizeof(*env
->sau
.rlar
) * cpu
->sau_sregion
);
338 /* SAU_CTRL reset value is IMPDEF; we choose 0, which is what
339 * the Cortex-M33 does.
344 set_flush_to_zero(1, &env
->vfp
.standard_fp_status
);
345 set_flush_inputs_to_zero(1, &env
->vfp
.standard_fp_status
);
346 set_default_nan_mode(1, &env
->vfp
.standard_fp_status
);
347 set_float_detect_tininess(float_tininess_before_rounding
,
348 &env
->vfp
.fp_status
);
349 set_float_detect_tininess(float_tininess_before_rounding
,
350 &env
->vfp
.standard_fp_status
);
351 set_float_detect_tininess(float_tininess_before_rounding
,
352 &env
->vfp
.fp_status_f16
);
353 #ifndef CONFIG_USER_ONLY
355 kvm_arm_reset_vcpu(cpu
);
359 hw_breakpoint_update_all(cpu
);
360 hw_watchpoint_update_all(cpu
);
363 bool arm_cpu_exec_interrupt(CPUState
*cs
, int interrupt_request
)
365 CPUClass
*cc
= CPU_GET_CLASS(cs
);
366 CPUARMState
*env
= cs
->env_ptr
;
367 uint32_t cur_el
= arm_current_el(env
);
368 bool secure
= arm_is_secure(env
);
373 if (interrupt_request
& CPU_INTERRUPT_FIQ
) {
375 target_el
= arm_phys_excp_target_el(cs
, excp_idx
, cur_el
, secure
);
376 if (arm_excp_unmasked(cs
, excp_idx
, target_el
)) {
377 cs
->exception_index
= excp_idx
;
378 env
->exception
.target_el
= target_el
;
379 cc
->do_interrupt(cs
);
383 if (interrupt_request
& CPU_INTERRUPT_HARD
) {
385 target_el
= arm_phys_excp_target_el(cs
, excp_idx
, cur_el
, secure
);
386 if (arm_excp_unmasked(cs
, excp_idx
, target_el
)) {
387 cs
->exception_index
= excp_idx
;
388 env
->exception
.target_el
= target_el
;
389 cc
->do_interrupt(cs
);
393 if (interrupt_request
& CPU_INTERRUPT_VIRQ
) {
394 excp_idx
= EXCP_VIRQ
;
396 if (arm_excp_unmasked(cs
, excp_idx
, target_el
)) {
397 cs
->exception_index
= excp_idx
;
398 env
->exception
.target_el
= target_el
;
399 cc
->do_interrupt(cs
);
403 if (interrupt_request
& CPU_INTERRUPT_VFIQ
) {
404 excp_idx
= EXCP_VFIQ
;
406 if (arm_excp_unmasked(cs
, excp_idx
, target_el
)) {
407 cs
->exception_index
= excp_idx
;
408 env
->exception
.target_el
= target_el
;
409 cc
->do_interrupt(cs
);
417 #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
418 static bool arm_v7m_cpu_exec_interrupt(CPUState
*cs
, int interrupt_request
)
420 CPUClass
*cc
= CPU_GET_CLASS(cs
);
421 ARMCPU
*cpu
= ARM_CPU(cs
);
422 CPUARMState
*env
= &cpu
->env
;
425 /* ARMv7-M interrupt masking works differently than -A or -R.
426 * There is no FIQ/IRQ distinction. Instead of I and F bits
427 * masking FIQ and IRQ interrupts, an exception is taken only
428 * if it is higher priority than the current execution priority
429 * (which depends on state like BASEPRI, FAULTMASK and the
430 * currently active exception).
432 if (interrupt_request
& CPU_INTERRUPT_HARD
433 && (armv7m_nvic_can_take_pending_exception(env
->nvic
))) {
434 cs
->exception_index
= EXCP_IRQ
;
435 cc
->do_interrupt(cs
);
442 void arm_cpu_update_virq(ARMCPU
*cpu
)
445 * Update the interrupt level for VIRQ, which is the logical OR of
446 * the HCR_EL2.VI bit and the input line level from the GIC.
448 CPUARMState
*env
= &cpu
->env
;
449 CPUState
*cs
= CPU(cpu
);
451 bool new_state
= (env
->cp15
.hcr_el2
& HCR_VI
) ||
452 (env
->irq_line_state
& CPU_INTERRUPT_VIRQ
);
454 if (new_state
!= ((cs
->interrupt_request
& CPU_INTERRUPT_VIRQ
) != 0)) {
456 cpu_interrupt(cs
, CPU_INTERRUPT_VIRQ
);
458 cpu_reset_interrupt(cs
, CPU_INTERRUPT_VIRQ
);
463 void arm_cpu_update_vfiq(ARMCPU
*cpu
)
466 * Update the interrupt level for VFIQ, which is the logical OR of
467 * the HCR_EL2.VF bit and the input line level from the GIC.
469 CPUARMState
*env
= &cpu
->env
;
470 CPUState
*cs
= CPU(cpu
);
472 bool new_state
= (env
->cp15
.hcr_el2
& HCR_VF
) ||
473 (env
->irq_line_state
& CPU_INTERRUPT_VFIQ
);
475 if (new_state
!= ((cs
->interrupt_request
& CPU_INTERRUPT_VFIQ
) != 0)) {
477 cpu_interrupt(cs
, CPU_INTERRUPT_VFIQ
);
479 cpu_reset_interrupt(cs
, CPU_INTERRUPT_VFIQ
);
484 #ifndef CONFIG_USER_ONLY
485 static void arm_cpu_set_irq(void *opaque
, int irq
, int level
)
487 ARMCPU
*cpu
= opaque
;
488 CPUARMState
*env
= &cpu
->env
;
489 CPUState
*cs
= CPU(cpu
);
490 static const int mask
[] = {
491 [ARM_CPU_IRQ
] = CPU_INTERRUPT_HARD
,
492 [ARM_CPU_FIQ
] = CPU_INTERRUPT_FIQ
,
493 [ARM_CPU_VIRQ
] = CPU_INTERRUPT_VIRQ
,
494 [ARM_CPU_VFIQ
] = CPU_INTERRUPT_VFIQ
498 env
->irq_line_state
|= mask
[irq
];
500 env
->irq_line_state
&= ~mask
[irq
];
505 assert(arm_feature(env
, ARM_FEATURE_EL2
));
506 arm_cpu_update_virq(cpu
);
509 assert(arm_feature(env
, ARM_FEATURE_EL2
));
510 arm_cpu_update_vfiq(cpu
);
515 cpu_interrupt(cs
, mask
[irq
]);
517 cpu_reset_interrupt(cs
, mask
[irq
]);
521 g_assert_not_reached();
525 static void arm_cpu_kvm_set_irq(void *opaque
, int irq
, int level
)
528 ARMCPU
*cpu
= opaque
;
529 CPUARMState
*env
= &cpu
->env
;
530 CPUState
*cs
= CPU(cpu
);
531 int kvm_irq
= KVM_ARM_IRQ_TYPE_CPU
<< KVM_ARM_IRQ_TYPE_SHIFT
;
532 uint32_t linestate_bit
;
536 kvm_irq
|= KVM_ARM_IRQ_CPU_IRQ
;
537 linestate_bit
= CPU_INTERRUPT_HARD
;
540 kvm_irq
|= KVM_ARM_IRQ_CPU_FIQ
;
541 linestate_bit
= CPU_INTERRUPT_FIQ
;
544 g_assert_not_reached();
548 env
->irq_line_state
|= linestate_bit
;
550 env
->irq_line_state
&= ~linestate_bit
;
553 kvm_irq
|= cs
->cpu_index
<< KVM_ARM_IRQ_VCPU_SHIFT
;
554 kvm_set_irq(kvm_state
, kvm_irq
, level
? 1 : 0);
558 static bool arm_cpu_virtio_is_big_endian(CPUState
*cs
)
560 ARMCPU
*cpu
= ARM_CPU(cs
);
561 CPUARMState
*env
= &cpu
->env
;
563 cpu_synchronize_state(cs
);
564 return arm_cpu_data_is_big_endian(env
);
569 static inline void set_feature(CPUARMState
*env
, int feature
)
571 env
->features
|= 1ULL << feature
;
574 static inline void unset_feature(CPUARMState
*env
, int feature
)
576 env
->features
&= ~(1ULL << feature
);
580 print_insn_thumb1(bfd_vma pc
, disassemble_info
*info
)
582 return print_insn_arm(pc
| 1, info
);
585 static void arm_disas_set_info(CPUState
*cpu
, disassemble_info
*info
)
587 ARMCPU
*ac
= ARM_CPU(cpu
);
588 CPUARMState
*env
= &ac
->env
;
592 /* We might not be compiled with the A64 disassembler
593 * because it needs a C++ compiler. Leave print_insn
594 * unset in this case to use the caller default behaviour.
596 #if defined(CONFIG_ARM_A64_DIS)
597 info
->print_insn
= print_insn_arm_a64
;
599 info
->cap_arch
= CS_ARCH_ARM64
;
600 info
->cap_insn_unit
= 4;
601 info
->cap_insn_split
= 4;
605 info
->print_insn
= print_insn_thumb1
;
606 info
->cap_insn_unit
= 2;
607 info
->cap_insn_split
= 4;
608 cap_mode
= CS_MODE_THUMB
;
610 info
->print_insn
= print_insn_arm
;
611 info
->cap_insn_unit
= 4;
612 info
->cap_insn_split
= 4;
613 cap_mode
= CS_MODE_ARM
;
615 if (arm_feature(env
, ARM_FEATURE_V8
)) {
616 cap_mode
|= CS_MODE_V8
;
618 if (arm_feature(env
, ARM_FEATURE_M
)) {
619 cap_mode
|= CS_MODE_MCLASS
;
621 info
->cap_arch
= CS_ARCH_ARM
;
622 info
->cap_mode
= cap_mode
;
625 sctlr_b
= arm_sctlr_b(env
);
626 if (bswap_code(sctlr_b
)) {
627 #ifdef TARGET_WORDS_BIGENDIAN
628 info
->endian
= BFD_ENDIAN_LITTLE
;
630 info
->endian
= BFD_ENDIAN_BIG
;
633 info
->flags
&= ~INSN_ARM_BE32
;
634 #ifndef CONFIG_USER_ONLY
636 info
->flags
|= INSN_ARM_BE32
;
641 uint64_t arm_cpu_mp_affinity(int idx
, uint8_t clustersz
)
643 uint32_t Aff1
= idx
/ clustersz
;
644 uint32_t Aff0
= idx
% clustersz
;
645 return (Aff1
<< ARM_AFF1_SHIFT
) | Aff0
;
648 static void cpreg_hashtable_data_destroy(gpointer data
)
651 * Destroy function for cpu->cp_regs hashtable data entries.
652 * We must free the name string because it was g_strdup()ed in
653 * add_cpreg_to_hashtable(). It's OK to cast away the 'const'
654 * from r->name because we know we definitely allocated it.
656 ARMCPRegInfo
*r
= data
;
658 g_free((void *)r
->name
);
662 static void arm_cpu_initfn(Object
*obj
)
664 CPUState
*cs
= CPU(obj
);
665 ARMCPU
*cpu
= ARM_CPU(obj
);
667 cs
->env_ptr
= &cpu
->env
;
668 cpu
->cp_regs
= g_hash_table_new_full(g_int_hash
, g_int_equal
,
669 g_free
, cpreg_hashtable_data_destroy
);
671 QLIST_INIT(&cpu
->pre_el_change_hooks
);
672 QLIST_INIT(&cpu
->el_change_hooks
);
674 #ifndef CONFIG_USER_ONLY
675 /* Our inbound IRQ and FIQ lines */
677 /* VIRQ and VFIQ are unused with KVM but we add them to maintain
678 * the same interface as non-KVM CPUs.
680 qdev_init_gpio_in(DEVICE(cpu
), arm_cpu_kvm_set_irq
, 4);
682 qdev_init_gpio_in(DEVICE(cpu
), arm_cpu_set_irq
, 4);
685 qdev_init_gpio_out(DEVICE(cpu
), cpu
->gt_timer_outputs
,
686 ARRAY_SIZE(cpu
->gt_timer_outputs
));
688 qdev_init_gpio_out_named(DEVICE(cpu
), &cpu
->gicv3_maintenance_interrupt
,
689 "gicv3-maintenance-interrupt", 1);
690 qdev_init_gpio_out_named(DEVICE(cpu
), &cpu
->pmu_interrupt
,
694 /* DTB consumers generally don't in fact care what the 'compatible'
695 * string is, so always provide some string and trust that a hypothetical
696 * picky DTB consumer will also provide a helpful error message.
698 cpu
->dtb_compatible
= "qemu,unknown";
699 cpu
->psci_version
= 1; /* By default assume PSCI v0.1 */
700 cpu
->kvm_target
= QEMU_KVM_ARM_TARGET_NONE
;
703 cpu
->psci_version
= 2; /* TCG implements PSCI 0.2 */
707 static Property arm_cpu_reset_cbar_property
=
708 DEFINE_PROP_UINT64("reset-cbar", ARMCPU
, reset_cbar
, 0);
710 static Property arm_cpu_reset_hivecs_property
=
711 DEFINE_PROP_BOOL("reset-hivecs", ARMCPU
, reset_hivecs
, false);
713 static Property arm_cpu_rvbar_property
=
714 DEFINE_PROP_UINT64("rvbar", ARMCPU
, rvbar
, 0);
716 static Property arm_cpu_has_el2_property
=
717 DEFINE_PROP_BOOL("has_el2", ARMCPU
, has_el2
, true);
719 static Property arm_cpu_has_el3_property
=
720 DEFINE_PROP_BOOL("has_el3", ARMCPU
, has_el3
, true);
722 static Property arm_cpu_cfgend_property
=
723 DEFINE_PROP_BOOL("cfgend", ARMCPU
, cfgend
, false);
725 /* use property name "pmu" to match other archs and virt tools */
726 static Property arm_cpu_has_pmu_property
=
727 DEFINE_PROP_BOOL("pmu", ARMCPU
, has_pmu
, true);
729 static Property arm_cpu_has_mpu_property
=
730 DEFINE_PROP_BOOL("has-mpu", ARMCPU
, has_mpu
, true);
732 /* This is like DEFINE_PROP_UINT32 but it doesn't set the default value,
733 * because the CPU initfn will have already set cpu->pmsav7_dregion to
734 * the right value for that particular CPU type, and we don't want
735 * to override that with an incorrect constant value.
737 static Property arm_cpu_pmsav7_dregion_property
=
738 DEFINE_PROP_UNSIGNED_NODEFAULT("pmsav7-dregion", ARMCPU
,
740 qdev_prop_uint32
, uint32_t);
742 /* M profile: initial value of the Secure VTOR */
743 static Property arm_cpu_initsvtor_property
=
744 DEFINE_PROP_UINT32("init-svtor", ARMCPU
, init_svtor
, 0);
746 void arm_cpu_post_init(Object
*obj
)
748 ARMCPU
*cpu
= ARM_CPU(obj
);
750 /* M profile implies PMSA. We have to do this here rather than
751 * in realize with the other feature-implication checks because
752 * we look at the PMSA bit to see if we should add some properties.
754 if (arm_feature(&cpu
->env
, ARM_FEATURE_M
)) {
755 set_feature(&cpu
->env
, ARM_FEATURE_PMSA
);
758 if (arm_feature(&cpu
->env
, ARM_FEATURE_CBAR
) ||
759 arm_feature(&cpu
->env
, ARM_FEATURE_CBAR_RO
)) {
760 qdev_property_add_static(DEVICE(obj
), &arm_cpu_reset_cbar_property
,
764 if (!arm_feature(&cpu
->env
, ARM_FEATURE_M
)) {
765 qdev_property_add_static(DEVICE(obj
), &arm_cpu_reset_hivecs_property
,
769 if (arm_feature(&cpu
->env
, ARM_FEATURE_AARCH64
)) {
770 qdev_property_add_static(DEVICE(obj
), &arm_cpu_rvbar_property
,
774 if (arm_feature(&cpu
->env
, ARM_FEATURE_EL3
)) {
775 /* Add the has_el3 state CPU property only if EL3 is allowed. This will
776 * prevent "has_el3" from existing on CPUs which cannot support EL3.
778 qdev_property_add_static(DEVICE(obj
), &arm_cpu_has_el3_property
,
781 #ifndef CONFIG_USER_ONLY
782 object_property_add_link(obj
, "secure-memory",
784 (Object
**)&cpu
->secure_memory
,
785 qdev_prop_allow_set_link_before_realize
,
786 OBJ_PROP_LINK_STRONG
,
791 if (arm_feature(&cpu
->env
, ARM_FEATURE_EL2
)) {
792 qdev_property_add_static(DEVICE(obj
), &arm_cpu_has_el2_property
,
796 if (arm_feature(&cpu
->env
, ARM_FEATURE_PMU
)) {
797 qdev_property_add_static(DEVICE(obj
), &arm_cpu_has_pmu_property
,
801 if (arm_feature(&cpu
->env
, ARM_FEATURE_PMSA
)) {
802 qdev_property_add_static(DEVICE(obj
), &arm_cpu_has_mpu_property
,
804 if (arm_feature(&cpu
->env
, ARM_FEATURE_V7
)) {
805 qdev_property_add_static(DEVICE(obj
),
806 &arm_cpu_pmsav7_dregion_property
,
811 if (arm_feature(&cpu
->env
, ARM_FEATURE_M_SECURITY
)) {
812 object_property_add_link(obj
, "idau", TYPE_IDAU_INTERFACE
, &cpu
->idau
,
813 qdev_prop_allow_set_link_before_realize
,
814 OBJ_PROP_LINK_STRONG
,
816 qdev_property_add_static(DEVICE(obj
), &arm_cpu_initsvtor_property
,
820 qdev_property_add_static(DEVICE(obj
), &arm_cpu_cfgend_property
,
824 static void arm_cpu_finalizefn(Object
*obj
)
826 ARMCPU
*cpu
= ARM_CPU(obj
);
827 ARMELChangeHook
*hook
, *next
;
829 g_hash_table_destroy(cpu
->cp_regs
);
831 QLIST_FOREACH_SAFE(hook
, &cpu
->pre_el_change_hooks
, node
, next
) {
832 QLIST_REMOVE(hook
, node
);
835 QLIST_FOREACH_SAFE(hook
, &cpu
->el_change_hooks
, node
, next
) {
836 QLIST_REMOVE(hook
, node
);
839 #ifndef CONFIG_USER_ONLY
840 if (cpu
->pmu_timer
) {
841 timer_del(cpu
->pmu_timer
);
842 timer_deinit(cpu
->pmu_timer
);
843 timer_free(cpu
->pmu_timer
);
848 static void arm_cpu_realizefn(DeviceState
*dev
, Error
**errp
)
850 CPUState
*cs
= CPU(dev
);
851 ARMCPU
*cpu
= ARM_CPU(dev
);
852 ARMCPUClass
*acc
= ARM_CPU_GET_CLASS(dev
);
853 CPUARMState
*env
= &cpu
->env
;
855 Error
*local_err
= NULL
;
856 bool no_aa32
= false;
858 /* If we needed to query the host kernel for the CPU features
859 * then it's possible that might have failed in the initfn, but
860 * this is the first point where we can report it.
862 if (cpu
->host_cpu_probe_failed
) {
863 if (!kvm_enabled()) {
864 error_setg(errp
, "The 'host' CPU type can only be used with KVM");
866 error_setg(errp
, "Failed to retrieve host CPU features");
871 #ifndef CONFIG_USER_ONLY
872 /* The NVIC and M-profile CPU are two halves of a single piece of
873 * hardware; trying to use one without the other is a command line
874 * error and will result in segfaults if not caught here.
876 if (arm_feature(env
, ARM_FEATURE_M
)) {
878 error_setg(errp
, "This board cannot be used with Cortex-M CPUs");
883 error_setg(errp
, "This board can only be used with Cortex-M CPUs");
888 cpu
->gt_timer
[GTIMER_PHYS
] = timer_new(QEMU_CLOCK_VIRTUAL
, GTIMER_SCALE
,
889 arm_gt_ptimer_cb
, cpu
);
890 cpu
->gt_timer
[GTIMER_VIRT
] = timer_new(QEMU_CLOCK_VIRTUAL
, GTIMER_SCALE
,
891 arm_gt_vtimer_cb
, cpu
);
892 cpu
->gt_timer
[GTIMER_HYP
] = timer_new(QEMU_CLOCK_VIRTUAL
, GTIMER_SCALE
,
893 arm_gt_htimer_cb
, cpu
);
894 cpu
->gt_timer
[GTIMER_SEC
] = timer_new(QEMU_CLOCK_VIRTUAL
, GTIMER_SCALE
,
895 arm_gt_stimer_cb
, cpu
);
898 cpu_exec_realizefn(cs
, &local_err
);
899 if (local_err
!= NULL
) {
900 error_propagate(errp
, local_err
);
904 /* Some features automatically imply others: */
905 if (arm_feature(env
, ARM_FEATURE_V8
)) {
906 if (arm_feature(env
, ARM_FEATURE_M
)) {
907 set_feature(env
, ARM_FEATURE_V7
);
909 set_feature(env
, ARM_FEATURE_V7VE
);
914 * There exist AArch64 cpus without AArch32 support. When KVM
915 * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN.
916 * Similarly, we cannot check ID_AA64PFR0 without AArch64 support.
918 if (arm_feature(&cpu
->env
, ARM_FEATURE_AARCH64
)) {
919 no_aa32
= !cpu_isar_feature(aa64_aa32
, cpu
);
922 if (arm_feature(env
, ARM_FEATURE_V7VE
)) {
923 /* v7 Virtualization Extensions. In real hardware this implies
924 * EL2 and also the presence of the Security Extensions.
925 * For QEMU, for backwards-compatibility we implement some
926 * CPUs or CPU configs which have no actual EL2 or EL3 but do
927 * include the various other features that V7VE implies.
928 * Presence of EL2 itself is ARM_FEATURE_EL2, and of the
929 * Security Extensions is ARM_FEATURE_EL3.
931 assert(no_aa32
|| cpu_isar_feature(arm_div
, cpu
));
932 set_feature(env
, ARM_FEATURE_LPAE
);
933 set_feature(env
, ARM_FEATURE_V7
);
935 if (arm_feature(env
, ARM_FEATURE_V7
)) {
936 set_feature(env
, ARM_FEATURE_VAPA
);
937 set_feature(env
, ARM_FEATURE_THUMB2
);
938 set_feature(env
, ARM_FEATURE_MPIDR
);
939 if (!arm_feature(env
, ARM_FEATURE_M
)) {
940 set_feature(env
, ARM_FEATURE_V6K
);
942 set_feature(env
, ARM_FEATURE_V6
);
945 /* Always define VBAR for V7 CPUs even if it doesn't exist in
946 * non-EL3 configs. This is needed by some legacy boards.
948 set_feature(env
, ARM_FEATURE_VBAR
);
950 if (arm_feature(env
, ARM_FEATURE_V6K
)) {
951 set_feature(env
, ARM_FEATURE_V6
);
952 set_feature(env
, ARM_FEATURE_MVFR
);
954 if (arm_feature(env
, ARM_FEATURE_V6
)) {
955 set_feature(env
, ARM_FEATURE_V5
);
956 if (!arm_feature(env
, ARM_FEATURE_M
)) {
957 assert(no_aa32
|| cpu_isar_feature(jazelle
, cpu
));
958 set_feature(env
, ARM_FEATURE_AUXCR
);
961 if (arm_feature(env
, ARM_FEATURE_V5
)) {
962 set_feature(env
, ARM_FEATURE_V4T
);
964 if (arm_feature(env
, ARM_FEATURE_VFP4
)) {
965 set_feature(env
, ARM_FEATURE_VFP3
);
966 set_feature(env
, ARM_FEATURE_VFP_FP16
);
968 if (arm_feature(env
, ARM_FEATURE_VFP3
)) {
969 set_feature(env
, ARM_FEATURE_VFP
);
971 if (arm_feature(env
, ARM_FEATURE_LPAE
)) {
972 set_feature(env
, ARM_FEATURE_V7MP
);
973 set_feature(env
, ARM_FEATURE_PXN
);
975 if (arm_feature(env
, ARM_FEATURE_CBAR_RO
)) {
976 set_feature(env
, ARM_FEATURE_CBAR
);
978 if (arm_feature(env
, ARM_FEATURE_THUMB2
) &&
979 !arm_feature(env
, ARM_FEATURE_M
)) {
980 set_feature(env
, ARM_FEATURE_THUMB_DSP
);
983 if (arm_feature(env
, ARM_FEATURE_V7
) &&
984 !arm_feature(env
, ARM_FEATURE_M
) &&
985 !arm_feature(env
, ARM_FEATURE_PMSA
)) {
986 /* v7VMSA drops support for the old ARMv5 tiny pages, so we
991 /* For CPUs which might have tiny 1K pages, or which have an
992 * MPU and might have small region sizes, stick with 1K pages.
996 if (!set_preferred_target_page_bits(pagebits
)) {
997 /* This can only ever happen for hotplugging a CPU, or if
998 * the board code incorrectly creates a CPU which it has
999 * promised via minimum_page_size that it will not.
1001 error_setg(errp
, "This CPU requires a smaller page size than the "
1006 /* This cpu-id-to-MPIDR affinity is used only for TCG; KVM will override it.
1007 * We don't support setting cluster ID ([16..23]) (known as Aff2
1008 * in later ARM ARM versions), or any of the higher affinity level fields,
1009 * so these bits always RAZ.
1011 if (cpu
->mp_affinity
== ARM64_AFFINITY_INVALID
) {
1012 cpu
->mp_affinity
= arm_cpu_mp_affinity(cs
->cpu_index
,
1013 ARM_DEFAULT_CPUS_PER_CLUSTER
);
1016 if (cpu
->reset_hivecs
) {
1017 cpu
->reset_sctlr
|= (1 << 13);
1021 if (arm_feature(&cpu
->env
, ARM_FEATURE_V7
)) {
1022 cpu
->reset_sctlr
|= SCTLR_EE
;
1024 cpu
->reset_sctlr
|= SCTLR_B
;
1028 if (!cpu
->has_el3
) {
1029 /* If the has_el3 CPU property is disabled then we need to disable the
1032 unset_feature(env
, ARM_FEATURE_EL3
);
1034 /* Disable the security extension feature bits in the processor feature
1035 * registers as well. These are id_pfr1[7:4] and id_aa64pfr0[15:12].
1037 cpu
->id_pfr1
&= ~0xf0;
1038 cpu
->isar
.id_aa64pfr0
&= ~0xf000;
1041 if (!cpu
->has_el2
) {
1042 unset_feature(env
, ARM_FEATURE_EL2
);
1045 if (!cpu
->has_pmu
) {
1046 unset_feature(env
, ARM_FEATURE_PMU
);
1048 if (arm_feature(env
, ARM_FEATURE_PMU
)) {
1051 if (!kvm_enabled()) {
1052 arm_register_pre_el_change_hook(cpu
, &pmu_pre_el_change
, 0);
1053 arm_register_el_change_hook(cpu
, &pmu_post_el_change
, 0);
1056 #ifndef CONFIG_USER_ONLY
1057 cpu
->pmu_timer
= timer_new_ns(QEMU_CLOCK_VIRTUAL
, arm_pmu_timer_cb
,
1061 cpu
->id_aa64dfr0
&= ~0xf00;
1066 if (!arm_feature(env
, ARM_FEATURE_EL2
)) {
1067 /* Disable the hypervisor feature bits in the processor feature
1068 * registers if we don't have EL2. These are id_pfr1[15:12] and
1069 * id_aa64pfr0_el1[11:8].
1071 cpu
->isar
.id_aa64pfr0
&= ~0xf00;
1072 cpu
->id_pfr1
&= ~0xf000;
1075 /* MPU can be configured out of a PMSA CPU either by setting has-mpu
1076 * to false or by setting pmsav7-dregion to 0.
1078 if (!cpu
->has_mpu
) {
1079 cpu
->pmsav7_dregion
= 0;
1081 if (cpu
->pmsav7_dregion
== 0) {
1082 cpu
->has_mpu
= false;
1085 if (arm_feature(env
, ARM_FEATURE_PMSA
) &&
1086 arm_feature(env
, ARM_FEATURE_V7
)) {
1087 uint32_t nr
= cpu
->pmsav7_dregion
;
1090 error_setg(errp
, "PMSAv7 MPU #regions invalid %" PRIu32
, nr
);
1095 if (arm_feature(env
, ARM_FEATURE_V8
)) {
1097 env
->pmsav8
.rbar
[M_REG_NS
] = g_new0(uint32_t, nr
);
1098 env
->pmsav8
.rlar
[M_REG_NS
] = g_new0(uint32_t, nr
);
1099 if (arm_feature(env
, ARM_FEATURE_M_SECURITY
)) {
1100 env
->pmsav8
.rbar
[M_REG_S
] = g_new0(uint32_t, nr
);
1101 env
->pmsav8
.rlar
[M_REG_S
] = g_new0(uint32_t, nr
);
1104 env
->pmsav7
.drbar
= g_new0(uint32_t, nr
);
1105 env
->pmsav7
.drsr
= g_new0(uint32_t, nr
);
1106 env
->pmsav7
.dracr
= g_new0(uint32_t, nr
);
1111 if (arm_feature(env
, ARM_FEATURE_M_SECURITY
)) {
1112 uint32_t nr
= cpu
->sau_sregion
;
1115 error_setg(errp
, "v8M SAU #regions invalid %" PRIu32
, nr
);
1120 env
->sau
.rbar
= g_new0(uint32_t, nr
);
1121 env
->sau
.rlar
= g_new0(uint32_t, nr
);
1125 if (arm_feature(env
, ARM_FEATURE_EL3
)) {
1126 set_feature(env
, ARM_FEATURE_VBAR
);
1129 register_cp_regs_for_features(cpu
);
1130 arm_cpu_register_gdb_regs_for_features(cpu
);
1132 init_cpreg_list(cpu
);
1134 #ifndef CONFIG_USER_ONLY
1135 if (cpu
->has_el3
|| arm_feature(env
, ARM_FEATURE_M_SECURITY
)) {
1138 if (!cpu
->secure_memory
) {
1139 cpu
->secure_memory
= cs
->memory
;
1141 cpu_address_space_init(cs
, ARMASIdx_S
, "cpu-secure-memory",
1142 cpu
->secure_memory
);
1146 cpu_address_space_init(cs
, ARMASIdx_NS
, "cpu-memory", cs
->memory
);
1148 /* No core_count specified, default to smp_cpus. */
1149 if (cpu
->core_count
== -1) {
1150 cpu
->core_count
= smp_cpus
;
1157 acc
->parent_realize(dev
, errp
);
1160 static ObjectClass
*arm_cpu_class_by_name(const char *cpu_model
)
1165 const char *cpunamestr
;
1167 cpuname
= g_strsplit(cpu_model
, ",", 1);
1168 cpunamestr
= cpuname
[0];
1169 #ifdef CONFIG_USER_ONLY
1170 /* For backwards compatibility usermode emulation allows "-cpu any",
1171 * which has the same semantics as "-cpu max".
1173 if (!strcmp(cpunamestr
, "any")) {
1177 typename
= g_strdup_printf(ARM_CPU_TYPE_NAME("%s"), cpunamestr
);
1178 oc
= object_class_by_name(typename
);
1179 g_strfreev(cpuname
);
1181 if (!oc
|| !object_class_dynamic_cast(oc
, TYPE_ARM_CPU
) ||
1182 object_class_is_abstract(oc
)) {
1188 /* CPU models. These are not needed for the AArch64 linux-user build. */
1189 #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
1191 static void arm926_initfn(Object
*obj
)
1193 ARMCPU
*cpu
= ARM_CPU(obj
);
1195 cpu
->dtb_compatible
= "arm,arm926";
1196 set_feature(&cpu
->env
, ARM_FEATURE_V5
);
1197 set_feature(&cpu
->env
, ARM_FEATURE_VFP
);
1198 set_feature(&cpu
->env
, ARM_FEATURE_DUMMY_C15_REGS
);
1199 set_feature(&cpu
->env
, ARM_FEATURE_CACHE_TEST_CLEAN
);
1200 cpu
->midr
= 0x41069265;
1201 cpu
->reset_fpsid
= 0x41011090;
1202 cpu
->ctr
= 0x1dd20d2;
1203 cpu
->reset_sctlr
= 0x00090078;
1206 * ARMv5 does not have the ID_ISAR registers, but we can still
1207 * set the field to indicate Jazelle support within QEMU.
1209 cpu
->isar
.id_isar1
= FIELD_DP32(cpu
->isar
.id_isar1
, ID_ISAR1
, JAZELLE
, 1);
1212 static void arm946_initfn(Object
*obj
)
1214 ARMCPU
*cpu
= ARM_CPU(obj
);
1216 cpu
->dtb_compatible
= "arm,arm946";
1217 set_feature(&cpu
->env
, ARM_FEATURE_V5
);
1218 set_feature(&cpu
->env
, ARM_FEATURE_PMSA
);
1219 set_feature(&cpu
->env
, ARM_FEATURE_DUMMY_C15_REGS
);
1220 cpu
->midr
= 0x41059461;
1221 cpu
->ctr
= 0x0f004006;
1222 cpu
->reset_sctlr
= 0x00000078;
1225 static void arm1026_initfn(Object
*obj
)
1227 ARMCPU
*cpu
= ARM_CPU(obj
);
1229 cpu
->dtb_compatible
= "arm,arm1026";
1230 set_feature(&cpu
->env
, ARM_FEATURE_V5
);
1231 set_feature(&cpu
->env
, ARM_FEATURE_VFP
);
1232 set_feature(&cpu
->env
, ARM_FEATURE_AUXCR
);
1233 set_feature(&cpu
->env
, ARM_FEATURE_DUMMY_C15_REGS
);
1234 set_feature(&cpu
->env
, ARM_FEATURE_CACHE_TEST_CLEAN
);
1235 cpu
->midr
= 0x4106a262;
1236 cpu
->reset_fpsid
= 0x410110a0;
1237 cpu
->ctr
= 0x1dd20d2;
1238 cpu
->reset_sctlr
= 0x00090078;
1239 cpu
->reset_auxcr
= 1;
1242 * ARMv5 does not have the ID_ISAR registers, but we can still
1243 * set the field to indicate Jazelle support within QEMU.
1245 cpu
->isar
.id_isar1
= FIELD_DP32(cpu
->isar
.id_isar1
, ID_ISAR1
, JAZELLE
, 1);
1248 /* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */
1249 ARMCPRegInfo ifar
= {
1250 .name
= "IFAR", .cp
= 15, .crn
= 6, .crm
= 0, .opc1
= 0, .opc2
= 1,
1252 .fieldoffset
= offsetof(CPUARMState
, cp15
.ifar_ns
),
1255 define_one_arm_cp_reg(cpu
, &ifar
);
1259 static void arm1136_r2_initfn(Object
*obj
)
1261 ARMCPU
*cpu
= ARM_CPU(obj
);
1262 /* What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an
1263 * older core than plain "arm1136". In particular this does not
1264 * have the v6K features.
1265 * These ID register values are correct for 1136 but may be wrong
1266 * for 1136_r2 (in particular r0p2 does not actually implement most
1267 * of the ID registers).
1270 cpu
->dtb_compatible
= "arm,arm1136";
1271 set_feature(&cpu
->env
, ARM_FEATURE_V6
);
1272 set_feature(&cpu
->env
, ARM_FEATURE_VFP
);
1273 set_feature(&cpu
->env
, ARM_FEATURE_DUMMY_C15_REGS
);
1274 set_feature(&cpu
->env
, ARM_FEATURE_CACHE_DIRTY_REG
);
1275 set_feature(&cpu
->env
, ARM_FEATURE_CACHE_BLOCK_OPS
);
1276 cpu
->midr
= 0x4107b362;
1277 cpu
->reset_fpsid
= 0x410120b4;
1278 cpu
->isar
.mvfr0
= 0x11111111;
1279 cpu
->isar
.mvfr1
= 0x00000000;
1280 cpu
->ctr
= 0x1dd20d2;
1281 cpu
->reset_sctlr
= 0x00050078;
1282 cpu
->id_pfr0
= 0x111;
1286 cpu
->id_mmfr0
= 0x01130003;
1287 cpu
->id_mmfr1
= 0x10030302;
1288 cpu
->id_mmfr2
= 0x01222110;
1289 cpu
->isar
.id_isar0
= 0x00140011;
1290 cpu
->isar
.id_isar1
= 0x12002111;
1291 cpu
->isar
.id_isar2
= 0x11231111;
1292 cpu
->isar
.id_isar3
= 0x01102131;
1293 cpu
->isar
.id_isar4
= 0x141;
1294 cpu
->reset_auxcr
= 7;
1297 static void arm1136_initfn(Object
*obj
)
1299 ARMCPU
*cpu
= ARM_CPU(obj
);
1301 cpu
->dtb_compatible
= "arm,arm1136";
1302 set_feature(&cpu
->env
, ARM_FEATURE_V6K
);
1303 set_feature(&cpu
->env
, ARM_FEATURE_V6
);
1304 set_feature(&cpu
->env
, ARM_FEATURE_VFP
);
1305 set_feature(&cpu
->env
, ARM_FEATURE_DUMMY_C15_REGS
);
1306 set_feature(&cpu
->env
, ARM_FEATURE_CACHE_DIRTY_REG
);
1307 set_feature(&cpu
->env
, ARM_FEATURE_CACHE_BLOCK_OPS
);
1308 cpu
->midr
= 0x4117b363;
1309 cpu
->reset_fpsid
= 0x410120b4;
1310 cpu
->isar
.mvfr0
= 0x11111111;
1311 cpu
->isar
.mvfr1
= 0x00000000;
1312 cpu
->ctr
= 0x1dd20d2;
1313 cpu
->reset_sctlr
= 0x00050078;
1314 cpu
->id_pfr0
= 0x111;
1318 cpu
->id_mmfr0
= 0x01130003;
1319 cpu
->id_mmfr1
= 0x10030302;
1320 cpu
->id_mmfr2
= 0x01222110;
1321 cpu
->isar
.id_isar0
= 0x00140011;
1322 cpu
->isar
.id_isar1
= 0x12002111;
1323 cpu
->isar
.id_isar2
= 0x11231111;
1324 cpu
->isar
.id_isar3
= 0x01102131;
1325 cpu
->isar
.id_isar4
= 0x141;
1326 cpu
->reset_auxcr
= 7;
1329 static void arm1176_initfn(Object
*obj
)
1331 ARMCPU
*cpu
= ARM_CPU(obj
);
1333 cpu
->dtb_compatible
= "arm,arm1176";
1334 set_feature(&cpu
->env
, ARM_FEATURE_V6K
);
1335 set_feature(&cpu
->env
, ARM_FEATURE_VFP
);
1336 set_feature(&cpu
->env
, ARM_FEATURE_VAPA
);
1337 set_feature(&cpu
->env
, ARM_FEATURE_DUMMY_C15_REGS
);
1338 set_feature(&cpu
->env
, ARM_FEATURE_CACHE_DIRTY_REG
);
1339 set_feature(&cpu
->env
, ARM_FEATURE_CACHE_BLOCK_OPS
);
1340 set_feature(&cpu
->env
, ARM_FEATURE_EL3
);
1341 cpu
->midr
= 0x410fb767;
1342 cpu
->reset_fpsid
= 0x410120b5;
1343 cpu
->isar
.mvfr0
= 0x11111111;
1344 cpu
->isar
.mvfr1
= 0x00000000;
1345 cpu
->ctr
= 0x1dd20d2;
1346 cpu
->reset_sctlr
= 0x00050078;
1347 cpu
->id_pfr0
= 0x111;
1348 cpu
->id_pfr1
= 0x11;
1349 cpu
->id_dfr0
= 0x33;
1351 cpu
->id_mmfr0
= 0x01130003;
1352 cpu
->id_mmfr1
= 0x10030302;
1353 cpu
->id_mmfr2
= 0x01222100;
1354 cpu
->isar
.id_isar0
= 0x0140011;
1355 cpu
->isar
.id_isar1
= 0x12002111;
1356 cpu
->isar
.id_isar2
= 0x11231121;
1357 cpu
->isar
.id_isar3
= 0x01102131;
1358 cpu
->isar
.id_isar4
= 0x01141;
1359 cpu
->reset_auxcr
= 7;
1362 static void arm11mpcore_initfn(Object
*obj
)
1364 ARMCPU
*cpu
= ARM_CPU(obj
);
1366 cpu
->dtb_compatible
= "arm,arm11mpcore";
1367 set_feature(&cpu
->env
, ARM_FEATURE_V6K
);
1368 set_feature(&cpu
->env
, ARM_FEATURE_VFP
);
1369 set_feature(&cpu
->env
, ARM_FEATURE_VAPA
);
1370 set_feature(&cpu
->env
, ARM_FEATURE_MPIDR
);
1371 set_feature(&cpu
->env
, ARM_FEATURE_DUMMY_C15_REGS
);
1372 cpu
->midr
= 0x410fb022;
1373 cpu
->reset_fpsid
= 0x410120b4;
1374 cpu
->isar
.mvfr0
= 0x11111111;
1375 cpu
->isar
.mvfr1
= 0x00000000;
1376 cpu
->ctr
= 0x1d192992; /* 32K icache 32K dcache */
1377 cpu
->id_pfr0
= 0x111;
1381 cpu
->id_mmfr0
= 0x01100103;
1382 cpu
->id_mmfr1
= 0x10020302;
1383 cpu
->id_mmfr2
= 0x01222000;
1384 cpu
->isar
.id_isar0
= 0x00100011;
1385 cpu
->isar
.id_isar1
= 0x12002111;
1386 cpu
->isar
.id_isar2
= 0x11221011;
1387 cpu
->isar
.id_isar3
= 0x01102131;
1388 cpu
->isar
.id_isar4
= 0x141;
1389 cpu
->reset_auxcr
= 1;
1392 static void cortex_m0_initfn(Object
*obj
)
1394 ARMCPU
*cpu
= ARM_CPU(obj
);
1395 set_feature(&cpu
->env
, ARM_FEATURE_V6
);
1396 set_feature(&cpu
->env
, ARM_FEATURE_M
);
1398 cpu
->midr
= 0x410cc200;
1401 static void cortex_m3_initfn(Object
*obj
)
1403 ARMCPU
*cpu
= ARM_CPU(obj
);
1404 set_feature(&cpu
->env
, ARM_FEATURE_V7
);
1405 set_feature(&cpu
->env
, ARM_FEATURE_M
);
1406 set_feature(&cpu
->env
, ARM_FEATURE_M_MAIN
);
1407 cpu
->midr
= 0x410fc231;
1408 cpu
->pmsav7_dregion
= 8;
1409 cpu
->id_pfr0
= 0x00000030;
1410 cpu
->id_pfr1
= 0x00000200;
1411 cpu
->id_dfr0
= 0x00100000;
1412 cpu
->id_afr0
= 0x00000000;
1413 cpu
->id_mmfr0
= 0x00000030;
1414 cpu
->id_mmfr1
= 0x00000000;
1415 cpu
->id_mmfr2
= 0x00000000;
1416 cpu
->id_mmfr3
= 0x00000000;
1417 cpu
->isar
.id_isar0
= 0x01141110;
1418 cpu
->isar
.id_isar1
= 0x02111000;
1419 cpu
->isar
.id_isar2
= 0x21112231;
1420 cpu
->isar
.id_isar3
= 0x01111110;
1421 cpu
->isar
.id_isar4
= 0x01310102;
1422 cpu
->isar
.id_isar5
= 0x00000000;
1423 cpu
->isar
.id_isar6
= 0x00000000;
1426 static void cortex_m4_initfn(Object
*obj
)
1428 ARMCPU
*cpu
= ARM_CPU(obj
);
1430 set_feature(&cpu
->env
, ARM_FEATURE_V7
);
1431 set_feature(&cpu
->env
, ARM_FEATURE_M
);
1432 set_feature(&cpu
->env
, ARM_FEATURE_M_MAIN
);
1433 set_feature(&cpu
->env
, ARM_FEATURE_THUMB_DSP
);
1434 cpu
->midr
= 0x410fc240; /* r0p0 */
1435 cpu
->pmsav7_dregion
= 8;
1436 cpu
->id_pfr0
= 0x00000030;
1437 cpu
->id_pfr1
= 0x00000200;
1438 cpu
->id_dfr0
= 0x00100000;
1439 cpu
->id_afr0
= 0x00000000;
1440 cpu
->id_mmfr0
= 0x00000030;
1441 cpu
->id_mmfr1
= 0x00000000;
1442 cpu
->id_mmfr2
= 0x00000000;
1443 cpu
->id_mmfr3
= 0x00000000;
1444 cpu
->isar
.id_isar0
= 0x01141110;
1445 cpu
->isar
.id_isar1
= 0x02111000;
1446 cpu
->isar
.id_isar2
= 0x21112231;
1447 cpu
->isar
.id_isar3
= 0x01111110;
1448 cpu
->isar
.id_isar4
= 0x01310102;
1449 cpu
->isar
.id_isar5
= 0x00000000;
1450 cpu
->isar
.id_isar6
= 0x00000000;
1453 static void cortex_m33_initfn(Object
*obj
)
1455 ARMCPU
*cpu
= ARM_CPU(obj
);
1457 set_feature(&cpu
->env
, ARM_FEATURE_V8
);
1458 set_feature(&cpu
->env
, ARM_FEATURE_M
);
1459 set_feature(&cpu
->env
, ARM_FEATURE_M_MAIN
);
1460 set_feature(&cpu
->env
, ARM_FEATURE_M_SECURITY
);
1461 set_feature(&cpu
->env
, ARM_FEATURE_THUMB_DSP
);
1462 cpu
->midr
= 0x410fd213; /* r0p3 */
1463 cpu
->pmsav7_dregion
= 16;
1464 cpu
->sau_sregion
= 8;
1465 cpu
->id_pfr0
= 0x00000030;
1466 cpu
->id_pfr1
= 0x00000210;
1467 cpu
->id_dfr0
= 0x00200000;
1468 cpu
->id_afr0
= 0x00000000;
1469 cpu
->id_mmfr0
= 0x00101F40;
1470 cpu
->id_mmfr1
= 0x00000000;
1471 cpu
->id_mmfr2
= 0x01000000;
1472 cpu
->id_mmfr3
= 0x00000000;
1473 cpu
->isar
.id_isar0
= 0x01101110;
1474 cpu
->isar
.id_isar1
= 0x02212000;
1475 cpu
->isar
.id_isar2
= 0x20232232;
1476 cpu
->isar
.id_isar3
= 0x01111131;
1477 cpu
->isar
.id_isar4
= 0x01310132;
1478 cpu
->isar
.id_isar5
= 0x00000000;
1479 cpu
->isar
.id_isar6
= 0x00000000;
1480 cpu
->clidr
= 0x00000000;
1481 cpu
->ctr
= 0x8000c000;
1484 static void arm_v7m_class_init(ObjectClass
*oc
, void *data
)
1486 ARMCPUClass
*acc
= ARM_CPU_CLASS(oc
);
1487 CPUClass
*cc
= CPU_CLASS(oc
);
1490 #ifndef CONFIG_USER_ONLY
1491 cc
->do_interrupt
= arm_v7m_cpu_do_interrupt
;
1494 cc
->cpu_exec_interrupt
= arm_v7m_cpu_exec_interrupt
;
1497 static const ARMCPRegInfo cortexr5_cp_reginfo
[] = {
1498 /* Dummy the TCM region regs for the moment */
1499 { .name
= "ATCM", .cp
= 15, .opc1
= 0, .crn
= 9, .crm
= 1, .opc2
= 0,
1500 .access
= PL1_RW
, .type
= ARM_CP_CONST
},
1501 { .name
= "BTCM", .cp
= 15, .opc1
= 0, .crn
= 9, .crm
= 1, .opc2
= 1,
1502 .access
= PL1_RW
, .type
= ARM_CP_CONST
},
1503 { .name
= "DCACHE_INVAL", .cp
= 15, .opc1
= 0, .crn
= 15, .crm
= 5,
1504 .opc2
= 0, .access
= PL1_W
, .type
= ARM_CP_NOP
},
1508 static void cortex_r5_initfn(Object
*obj
)
1510 ARMCPU
*cpu
= ARM_CPU(obj
);
1512 set_feature(&cpu
->env
, ARM_FEATURE_V7
);
1513 set_feature(&cpu
->env
, ARM_FEATURE_V7MP
);
1514 set_feature(&cpu
->env
, ARM_FEATURE_PMSA
);
1515 cpu
->midr
= 0x411fc153; /* r1p3 */
1516 cpu
->id_pfr0
= 0x0131;
1517 cpu
->id_pfr1
= 0x001;
1518 cpu
->id_dfr0
= 0x010400;
1520 cpu
->id_mmfr0
= 0x0210030;
1521 cpu
->id_mmfr1
= 0x00000000;
1522 cpu
->id_mmfr2
= 0x01200000;
1523 cpu
->id_mmfr3
= 0x0211;
1524 cpu
->isar
.id_isar0
= 0x02101111;
1525 cpu
->isar
.id_isar1
= 0x13112111;
1526 cpu
->isar
.id_isar2
= 0x21232141;
1527 cpu
->isar
.id_isar3
= 0x01112131;
1528 cpu
->isar
.id_isar4
= 0x0010142;
1529 cpu
->isar
.id_isar5
= 0x0;
1530 cpu
->isar
.id_isar6
= 0x0;
1531 cpu
->mp_is_up
= true;
1532 cpu
->pmsav7_dregion
= 16;
1533 define_arm_cp_regs(cpu
, cortexr5_cp_reginfo
);
1536 static void cortex_r5f_initfn(Object
*obj
)
1538 ARMCPU
*cpu
= ARM_CPU(obj
);
1540 cortex_r5_initfn(obj
);
1541 set_feature(&cpu
->env
, ARM_FEATURE_VFP3
);
1544 static const ARMCPRegInfo cortexa8_cp_reginfo
[] = {
1545 { .name
= "L2LOCKDOWN", .cp
= 15, .crn
= 9, .crm
= 0, .opc1
= 1, .opc2
= 0,
1546 .access
= PL1_RW
, .type
= ARM_CP_CONST
, .resetvalue
= 0 },
1547 { .name
= "L2AUXCR", .cp
= 15, .crn
= 9, .crm
= 0, .opc1
= 1, .opc2
= 2,
1548 .access
= PL1_RW
, .type
= ARM_CP_CONST
, .resetvalue
= 0 },
1552 static void cortex_a8_initfn(Object
*obj
)
1554 ARMCPU
*cpu
= ARM_CPU(obj
);
1556 cpu
->dtb_compatible
= "arm,cortex-a8";
1557 set_feature(&cpu
->env
, ARM_FEATURE_V7
);
1558 set_feature(&cpu
->env
, ARM_FEATURE_VFP3
);
1559 set_feature(&cpu
->env
, ARM_FEATURE_NEON
);
1560 set_feature(&cpu
->env
, ARM_FEATURE_THUMB2EE
);
1561 set_feature(&cpu
->env
, ARM_FEATURE_DUMMY_C15_REGS
);
1562 set_feature(&cpu
->env
, ARM_FEATURE_EL3
);
1563 cpu
->midr
= 0x410fc080;
1564 cpu
->reset_fpsid
= 0x410330c0;
1565 cpu
->isar
.mvfr0
= 0x11110222;
1566 cpu
->isar
.mvfr1
= 0x00011111;
1567 cpu
->ctr
= 0x82048004;
1568 cpu
->reset_sctlr
= 0x00c50078;
1569 cpu
->id_pfr0
= 0x1031;
1570 cpu
->id_pfr1
= 0x11;
1571 cpu
->id_dfr0
= 0x400;
1573 cpu
->id_mmfr0
= 0x31100003;
1574 cpu
->id_mmfr1
= 0x20000000;
1575 cpu
->id_mmfr2
= 0x01202000;
1576 cpu
->id_mmfr3
= 0x11;
1577 cpu
->isar
.id_isar0
= 0x00101111;
1578 cpu
->isar
.id_isar1
= 0x12112111;
1579 cpu
->isar
.id_isar2
= 0x21232031;
1580 cpu
->isar
.id_isar3
= 0x11112131;
1581 cpu
->isar
.id_isar4
= 0x00111142;
1582 cpu
->dbgdidr
= 0x15141000;
1583 cpu
->clidr
= (1 << 27) | (2 << 24) | 3;
1584 cpu
->ccsidr
[0] = 0xe007e01a; /* 16k L1 dcache. */
1585 cpu
->ccsidr
[1] = 0x2007e01a; /* 16k L1 icache. */
1586 cpu
->ccsidr
[2] = 0xf0000000; /* No L2 icache. */
1587 cpu
->reset_auxcr
= 2;
1588 define_arm_cp_regs(cpu
, cortexa8_cp_reginfo
);
1591 static const ARMCPRegInfo cortexa9_cp_reginfo
[] = {
1592 /* power_control should be set to maximum latency. Again,
1593 * default to 0 and set by private hook
1595 { .name
= "A9_PWRCTL", .cp
= 15, .crn
= 15, .crm
= 0, .opc1
= 0, .opc2
= 0,
1596 .access
= PL1_RW
, .resetvalue
= 0,
1597 .fieldoffset
= offsetof(CPUARMState
, cp15
.c15_power_control
) },
1598 { .name
= "A9_DIAG", .cp
= 15, .crn
= 15, .crm
= 0, .opc1
= 0, .opc2
= 1,
1599 .access
= PL1_RW
, .resetvalue
= 0,
1600 .fieldoffset
= offsetof(CPUARMState
, cp15
.c15_diagnostic
) },
1601 { .name
= "A9_PWRDIAG", .cp
= 15, .crn
= 15, .crm
= 0, .opc1
= 0, .opc2
= 2,
1602 .access
= PL1_RW
, .resetvalue
= 0,
1603 .fieldoffset
= offsetof(CPUARMState
, cp15
.c15_power_diagnostic
) },
1604 { .name
= "NEONBUSY", .cp
= 15, .crn
= 15, .crm
= 1, .opc1
= 0, .opc2
= 0,
1605 .access
= PL1_RW
, .resetvalue
= 0, .type
= ARM_CP_CONST
},
1606 /* TLB lockdown control */
1607 { .name
= "TLB_LOCKR", .cp
= 15, .crn
= 15, .crm
= 4, .opc1
= 5, .opc2
= 2,
1608 .access
= PL1_W
, .resetvalue
= 0, .type
= ARM_CP_NOP
},
1609 { .name
= "TLB_LOCKW", .cp
= 15, .crn
= 15, .crm
= 4, .opc1
= 5, .opc2
= 4,
1610 .access
= PL1_W
, .resetvalue
= 0, .type
= ARM_CP_NOP
},
1611 { .name
= "TLB_VA", .cp
= 15, .crn
= 15, .crm
= 5, .opc1
= 5, .opc2
= 2,
1612 .access
= PL1_RW
, .resetvalue
= 0, .type
= ARM_CP_CONST
},
1613 { .name
= "TLB_PA", .cp
= 15, .crn
= 15, .crm
= 6, .opc1
= 5, .opc2
= 2,
1614 .access
= PL1_RW
, .resetvalue
= 0, .type
= ARM_CP_CONST
},
1615 { .name
= "TLB_ATTR", .cp
= 15, .crn
= 15, .crm
= 7, .opc1
= 5, .opc2
= 2,
1616 .access
= PL1_RW
, .resetvalue
= 0, .type
= ARM_CP_CONST
},
1620 static void cortex_a9_initfn(Object
*obj
)
1622 ARMCPU
*cpu
= ARM_CPU(obj
);
1624 cpu
->dtb_compatible
= "arm,cortex-a9";
1625 set_feature(&cpu
->env
, ARM_FEATURE_V7
);
1626 set_feature(&cpu
->env
, ARM_FEATURE_VFP3
);
1627 set_feature(&cpu
->env
, ARM_FEATURE_VFP_FP16
);
1628 set_feature(&cpu
->env
, ARM_FEATURE_NEON
);
1629 set_feature(&cpu
->env
, ARM_FEATURE_THUMB2EE
);
1630 set_feature(&cpu
->env
, ARM_FEATURE_EL3
);
1631 /* Note that A9 supports the MP extensions even for
1632 * A9UP and single-core A9MP (which are both different
1633 * and valid configurations; we don't model A9UP).
1635 set_feature(&cpu
->env
, ARM_FEATURE_V7MP
);
1636 set_feature(&cpu
->env
, ARM_FEATURE_CBAR
);
1637 cpu
->midr
= 0x410fc090;
1638 cpu
->reset_fpsid
= 0x41033090;
1639 cpu
->isar
.mvfr0
= 0x11110222;
1640 cpu
->isar
.mvfr1
= 0x01111111;
1641 cpu
->ctr
= 0x80038003;
1642 cpu
->reset_sctlr
= 0x00c50078;
1643 cpu
->id_pfr0
= 0x1031;
1644 cpu
->id_pfr1
= 0x11;
1645 cpu
->id_dfr0
= 0x000;
1647 cpu
->id_mmfr0
= 0x00100103;
1648 cpu
->id_mmfr1
= 0x20000000;
1649 cpu
->id_mmfr2
= 0x01230000;
1650 cpu
->id_mmfr3
= 0x00002111;
1651 cpu
->isar
.id_isar0
= 0x00101111;
1652 cpu
->isar
.id_isar1
= 0x13112111;
1653 cpu
->isar
.id_isar2
= 0x21232041;
1654 cpu
->isar
.id_isar3
= 0x11112131;
1655 cpu
->isar
.id_isar4
= 0x00111142;
1656 cpu
->dbgdidr
= 0x35141000;
1657 cpu
->clidr
= (1 << 27) | (1 << 24) | 3;
1658 cpu
->ccsidr
[0] = 0xe00fe019; /* 16k L1 dcache. */
1659 cpu
->ccsidr
[1] = 0x200fe019; /* 16k L1 icache. */
1660 define_arm_cp_regs(cpu
, cortexa9_cp_reginfo
);
1663 #ifndef CONFIG_USER_ONLY
1664 static uint64_t a15_l2ctlr_read(CPUARMState
*env
, const ARMCPRegInfo
*ri
)
1666 /* Linux wants the number of processors from here.
1667 * Might as well set the interrupt-controller bit too.
1669 return ((smp_cpus
- 1) << 24) | (1 << 23);
1673 static const ARMCPRegInfo cortexa15_cp_reginfo
[] = {
1674 #ifndef CONFIG_USER_ONLY
1675 { .name
= "L2CTLR", .cp
= 15, .crn
= 9, .crm
= 0, .opc1
= 1, .opc2
= 2,
1676 .access
= PL1_RW
, .resetvalue
= 0, .readfn
= a15_l2ctlr_read
,
1677 .writefn
= arm_cp_write_ignore
, },
1679 { .name
= "L2ECTLR", .cp
= 15, .crn
= 9, .crm
= 0, .opc1
= 1, .opc2
= 3,
1680 .access
= PL1_RW
, .type
= ARM_CP_CONST
, .resetvalue
= 0 },
1684 static void cortex_a7_initfn(Object
*obj
)
1686 ARMCPU
*cpu
= ARM_CPU(obj
);
1688 cpu
->dtb_compatible
= "arm,cortex-a7";
1689 set_feature(&cpu
->env
, ARM_FEATURE_V7VE
);
1690 set_feature(&cpu
->env
, ARM_FEATURE_VFP4
);
1691 set_feature(&cpu
->env
, ARM_FEATURE_NEON
);
1692 set_feature(&cpu
->env
, ARM_FEATURE_THUMB2EE
);
1693 set_feature(&cpu
->env
, ARM_FEATURE_GENERIC_TIMER
);
1694 set_feature(&cpu
->env
, ARM_FEATURE_DUMMY_C15_REGS
);
1695 set_feature(&cpu
->env
, ARM_FEATURE_CBAR_RO
);
1696 set_feature(&cpu
->env
, ARM_FEATURE_EL2
);
1697 set_feature(&cpu
->env
, ARM_FEATURE_EL3
);
1698 cpu
->kvm_target
= QEMU_KVM_ARM_TARGET_CORTEX_A7
;
1699 cpu
->midr
= 0x410fc075;
1700 cpu
->reset_fpsid
= 0x41023075;
1701 cpu
->isar
.mvfr0
= 0x10110222;
1702 cpu
->isar
.mvfr1
= 0x11111111;
1703 cpu
->ctr
= 0x84448003;
1704 cpu
->reset_sctlr
= 0x00c50078;
1705 cpu
->id_pfr0
= 0x00001131;
1706 cpu
->id_pfr1
= 0x00011011;
1707 cpu
->id_dfr0
= 0x02010555;
1708 cpu
->id_afr0
= 0x00000000;
1709 cpu
->id_mmfr0
= 0x10101105;
1710 cpu
->id_mmfr1
= 0x40000000;
1711 cpu
->id_mmfr2
= 0x01240000;
1712 cpu
->id_mmfr3
= 0x02102211;
1713 /* a7_mpcore_r0p5_trm, page 4-4 gives 0x01101110; but
1714 * table 4-41 gives 0x02101110, which includes the arm div insns.
1716 cpu
->isar
.id_isar0
= 0x02101110;
1717 cpu
->isar
.id_isar1
= 0x13112111;
1718 cpu
->isar
.id_isar2
= 0x21232041;
1719 cpu
->isar
.id_isar3
= 0x11112131;
1720 cpu
->isar
.id_isar4
= 0x10011142;
1721 cpu
->dbgdidr
= 0x3515f005;
1722 cpu
->clidr
= 0x0a200023;
1723 cpu
->ccsidr
[0] = 0x701fe00a; /* 32K L1 dcache */
1724 cpu
->ccsidr
[1] = 0x201fe00a; /* 32K L1 icache */
1725 cpu
->ccsidr
[2] = 0x711fe07a; /* 4096K L2 unified cache */
1726 define_arm_cp_regs(cpu
, cortexa15_cp_reginfo
); /* Same as A15 */
1729 static void cortex_a15_initfn(Object
*obj
)
1731 ARMCPU
*cpu
= ARM_CPU(obj
);
1733 cpu
->dtb_compatible
= "arm,cortex-a15";
1734 set_feature(&cpu
->env
, ARM_FEATURE_V7VE
);
1735 set_feature(&cpu
->env
, ARM_FEATURE_VFP4
);
1736 set_feature(&cpu
->env
, ARM_FEATURE_NEON
);
1737 set_feature(&cpu
->env
, ARM_FEATURE_THUMB2EE
);
1738 set_feature(&cpu
->env
, ARM_FEATURE_GENERIC_TIMER
);
1739 set_feature(&cpu
->env
, ARM_FEATURE_DUMMY_C15_REGS
);
1740 set_feature(&cpu
->env
, ARM_FEATURE_CBAR_RO
);
1741 set_feature(&cpu
->env
, ARM_FEATURE_EL2
);
1742 set_feature(&cpu
->env
, ARM_FEATURE_EL3
);
1743 cpu
->kvm_target
= QEMU_KVM_ARM_TARGET_CORTEX_A15
;
1744 cpu
->midr
= 0x412fc0f1;
1745 cpu
->reset_fpsid
= 0x410430f0;
1746 cpu
->isar
.mvfr0
= 0x10110222;
1747 cpu
->isar
.mvfr1
= 0x11111111;
1748 cpu
->ctr
= 0x8444c004;
1749 cpu
->reset_sctlr
= 0x00c50078;
1750 cpu
->id_pfr0
= 0x00001131;
1751 cpu
->id_pfr1
= 0x00011011;
1752 cpu
->id_dfr0
= 0x02010555;
1753 cpu
->id_afr0
= 0x00000000;
1754 cpu
->id_mmfr0
= 0x10201105;
1755 cpu
->id_mmfr1
= 0x20000000;
1756 cpu
->id_mmfr2
= 0x01240000;
1757 cpu
->id_mmfr3
= 0x02102211;
1758 cpu
->isar
.id_isar0
= 0x02101110;
1759 cpu
->isar
.id_isar1
= 0x13112111;
1760 cpu
->isar
.id_isar2
= 0x21232041;
1761 cpu
->isar
.id_isar3
= 0x11112131;
1762 cpu
->isar
.id_isar4
= 0x10011142;
1763 cpu
->dbgdidr
= 0x3515f021;
1764 cpu
->clidr
= 0x0a200023;
1765 cpu
->ccsidr
[0] = 0x701fe00a; /* 32K L1 dcache */
1766 cpu
->ccsidr
[1] = 0x201fe00a; /* 32K L1 icache */
1767 cpu
->ccsidr
[2] = 0x711fe07a; /* 4096K L2 unified cache */
1768 define_arm_cp_regs(cpu
, cortexa15_cp_reginfo
);
1771 static void ti925t_initfn(Object
*obj
)
1773 ARMCPU
*cpu
= ARM_CPU(obj
);
1774 set_feature(&cpu
->env
, ARM_FEATURE_V4T
);
1775 set_feature(&cpu
->env
, ARM_FEATURE_OMAPCP
);
1776 cpu
->midr
= ARM_CPUID_TI925T
;
1777 cpu
->ctr
= 0x5109149;
1778 cpu
->reset_sctlr
= 0x00000070;
1781 static void sa1100_initfn(Object
*obj
)
1783 ARMCPU
*cpu
= ARM_CPU(obj
);
1785 cpu
->dtb_compatible
= "intel,sa1100";
1786 set_feature(&cpu
->env
, ARM_FEATURE_STRONGARM
);
1787 set_feature(&cpu
->env
, ARM_FEATURE_DUMMY_C15_REGS
);
1788 cpu
->midr
= 0x4401A11B;
1789 cpu
->reset_sctlr
= 0x00000070;
1792 static void sa1110_initfn(Object
*obj
)
1794 ARMCPU
*cpu
= ARM_CPU(obj
);
1795 set_feature(&cpu
->env
, ARM_FEATURE_STRONGARM
);
1796 set_feature(&cpu
->env
, ARM_FEATURE_DUMMY_C15_REGS
);
1797 cpu
->midr
= 0x6901B119;
1798 cpu
->reset_sctlr
= 0x00000070;
1801 static void pxa250_initfn(Object
*obj
)
1803 ARMCPU
*cpu
= ARM_CPU(obj
);
1805 cpu
->dtb_compatible
= "marvell,xscale";
1806 set_feature(&cpu
->env
, ARM_FEATURE_V5
);
1807 set_feature(&cpu
->env
, ARM_FEATURE_XSCALE
);
1808 cpu
->midr
= 0x69052100;
1809 cpu
->ctr
= 0xd172172;
1810 cpu
->reset_sctlr
= 0x00000078;
1813 static void pxa255_initfn(Object
*obj
)
1815 ARMCPU
*cpu
= ARM_CPU(obj
);
1817 cpu
->dtb_compatible
= "marvell,xscale";
1818 set_feature(&cpu
->env
, ARM_FEATURE_V5
);
1819 set_feature(&cpu
->env
, ARM_FEATURE_XSCALE
);
1820 cpu
->midr
= 0x69052d00;
1821 cpu
->ctr
= 0xd172172;
1822 cpu
->reset_sctlr
= 0x00000078;
1825 static void pxa260_initfn(Object
*obj
)
1827 ARMCPU
*cpu
= ARM_CPU(obj
);
1829 cpu
->dtb_compatible
= "marvell,xscale";
1830 set_feature(&cpu
->env
, ARM_FEATURE_V5
);
1831 set_feature(&cpu
->env
, ARM_FEATURE_XSCALE
);
1832 cpu
->midr
= 0x69052903;
1833 cpu
->ctr
= 0xd172172;
1834 cpu
->reset_sctlr
= 0x00000078;
1837 static void pxa261_initfn(Object
*obj
)
1839 ARMCPU
*cpu
= ARM_CPU(obj
);
1841 cpu
->dtb_compatible
= "marvell,xscale";
1842 set_feature(&cpu
->env
, ARM_FEATURE_V5
);
1843 set_feature(&cpu
->env
, ARM_FEATURE_XSCALE
);
1844 cpu
->midr
= 0x69052d05;
1845 cpu
->ctr
= 0xd172172;
1846 cpu
->reset_sctlr
= 0x00000078;
1849 static void pxa262_initfn(Object
*obj
)
1851 ARMCPU
*cpu
= ARM_CPU(obj
);
1853 cpu
->dtb_compatible
= "marvell,xscale";
1854 set_feature(&cpu
->env
, ARM_FEATURE_V5
);
1855 set_feature(&cpu
->env
, ARM_FEATURE_XSCALE
);
1856 cpu
->midr
= 0x69052d06;
1857 cpu
->ctr
= 0xd172172;
1858 cpu
->reset_sctlr
= 0x00000078;
1861 static void pxa270a0_initfn(Object
*obj
)
1863 ARMCPU
*cpu
= ARM_CPU(obj
);
1865 cpu
->dtb_compatible
= "marvell,xscale";
1866 set_feature(&cpu
->env
, ARM_FEATURE_V5
);
1867 set_feature(&cpu
->env
, ARM_FEATURE_XSCALE
);
1868 set_feature(&cpu
->env
, ARM_FEATURE_IWMMXT
);
1869 cpu
->midr
= 0x69054110;
1870 cpu
->ctr
= 0xd172172;
1871 cpu
->reset_sctlr
= 0x00000078;
1874 static void pxa270a1_initfn(Object
*obj
)
1876 ARMCPU
*cpu
= ARM_CPU(obj
);
1878 cpu
->dtb_compatible
= "marvell,xscale";
1879 set_feature(&cpu
->env
, ARM_FEATURE_V5
);
1880 set_feature(&cpu
->env
, ARM_FEATURE_XSCALE
);
1881 set_feature(&cpu
->env
, ARM_FEATURE_IWMMXT
);
1882 cpu
->midr
= 0x69054111;
1883 cpu
->ctr
= 0xd172172;
1884 cpu
->reset_sctlr
= 0x00000078;
1887 static void pxa270b0_initfn(Object
*obj
)
1889 ARMCPU
*cpu
= ARM_CPU(obj
);
1891 cpu
->dtb_compatible
= "marvell,xscale";
1892 set_feature(&cpu
->env
, ARM_FEATURE_V5
);
1893 set_feature(&cpu
->env
, ARM_FEATURE_XSCALE
);
1894 set_feature(&cpu
->env
, ARM_FEATURE_IWMMXT
);
1895 cpu
->midr
= 0x69054112;
1896 cpu
->ctr
= 0xd172172;
1897 cpu
->reset_sctlr
= 0x00000078;
1900 static void pxa270b1_initfn(Object
*obj
)
1902 ARMCPU
*cpu
= ARM_CPU(obj
);
1904 cpu
->dtb_compatible
= "marvell,xscale";
1905 set_feature(&cpu
->env
, ARM_FEATURE_V5
);
1906 set_feature(&cpu
->env
, ARM_FEATURE_XSCALE
);
1907 set_feature(&cpu
->env
, ARM_FEATURE_IWMMXT
);
1908 cpu
->midr
= 0x69054113;
1909 cpu
->ctr
= 0xd172172;
1910 cpu
->reset_sctlr
= 0x00000078;
1913 static void pxa270c0_initfn(Object
*obj
)
1915 ARMCPU
*cpu
= ARM_CPU(obj
);
1917 cpu
->dtb_compatible
= "marvell,xscale";
1918 set_feature(&cpu
->env
, ARM_FEATURE_V5
);
1919 set_feature(&cpu
->env
, ARM_FEATURE_XSCALE
);
1920 set_feature(&cpu
->env
, ARM_FEATURE_IWMMXT
);
1921 cpu
->midr
= 0x69054114;
1922 cpu
->ctr
= 0xd172172;
1923 cpu
->reset_sctlr
= 0x00000078;
1926 static void pxa270c5_initfn(Object
*obj
)
1928 ARMCPU
*cpu
= ARM_CPU(obj
);
1930 cpu
->dtb_compatible
= "marvell,xscale";
1931 set_feature(&cpu
->env
, ARM_FEATURE_V5
);
1932 set_feature(&cpu
->env
, ARM_FEATURE_XSCALE
);
1933 set_feature(&cpu
->env
, ARM_FEATURE_IWMMXT
);
1934 cpu
->midr
= 0x69054117;
1935 cpu
->ctr
= 0xd172172;
1936 cpu
->reset_sctlr
= 0x00000078;
1939 #ifndef TARGET_AARCH64
1940 /* -cpu max: if KVM is enabled, like -cpu host (best possible with this host);
1941 * otherwise, a CPU with as many features enabled as our emulation supports.
1942 * The version of '-cpu max' for qemu-system-aarch64 is defined in cpu64.c;
1943 * this only needs to handle 32 bits.
1945 static void arm_max_initfn(Object
*obj
)
1947 ARMCPU
*cpu
= ARM_CPU(obj
);
1949 if (kvm_enabled()) {
1950 kvm_arm_set_cpu_features_from_host(cpu
);
1952 cortex_a15_initfn(obj
);
1953 #ifdef CONFIG_USER_ONLY
1954 /* We don't set these in system emulation mode for the moment,
1955 * since we don't correctly set (all of) the ID registers to
1958 set_feature(&cpu
->env
, ARM_FEATURE_V8
);
1962 t
= cpu
->isar
.id_isar5
;
1963 t
= FIELD_DP32(t
, ID_ISAR5
, AES
, 2);
1964 t
= FIELD_DP32(t
, ID_ISAR5
, SHA1
, 1);
1965 t
= FIELD_DP32(t
, ID_ISAR5
, SHA2
, 1);
1966 t
= FIELD_DP32(t
, ID_ISAR5
, CRC32
, 1);
1967 t
= FIELD_DP32(t
, ID_ISAR5
, RDM
, 1);
1968 t
= FIELD_DP32(t
, ID_ISAR5
, VCMA
, 1);
1969 cpu
->isar
.id_isar5
= t
;
1971 t
= cpu
->isar
.id_isar6
;
1972 t
= FIELD_DP32(t
, ID_ISAR6
, DP
, 1);
1973 cpu
->isar
.id_isar6
= t
;
1976 t
= FIELD_DP32(t
, ID_MMFR4
, HPDS
, 1); /* AA32HPD */
1984 #endif /* !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) */
1988 void (*initfn
)(Object
*obj
);
1989 void (*class_init
)(ObjectClass
*oc
, void *data
);
1992 static const ARMCPUInfo arm_cpus
[] = {
1993 #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
1994 { .name
= "arm926", .initfn
= arm926_initfn
},
1995 { .name
= "arm946", .initfn
= arm946_initfn
},
1996 { .name
= "arm1026", .initfn
= arm1026_initfn
},
1997 /* What QEMU calls "arm1136-r2" is actually the 1136 r0p2, i.e. an
1998 * older core than plain "arm1136". In particular this does not
1999 * have the v6K features.
2001 { .name
= "arm1136-r2", .initfn
= arm1136_r2_initfn
},
2002 { .name
= "arm1136", .initfn
= arm1136_initfn
},
2003 { .name
= "arm1176", .initfn
= arm1176_initfn
},
2004 { .name
= "arm11mpcore", .initfn
= arm11mpcore_initfn
},
2005 { .name
= "cortex-m0", .initfn
= cortex_m0_initfn
,
2006 .class_init
= arm_v7m_class_init
},
2007 { .name
= "cortex-m3", .initfn
= cortex_m3_initfn
,
2008 .class_init
= arm_v7m_class_init
},
2009 { .name
= "cortex-m4", .initfn
= cortex_m4_initfn
,
2010 .class_init
= arm_v7m_class_init
},
2011 { .name
= "cortex-m33", .initfn
= cortex_m33_initfn
,
2012 .class_init
= arm_v7m_class_init
},
2013 { .name
= "cortex-r5", .initfn
= cortex_r5_initfn
},
2014 { .name
= "cortex-r5f", .initfn
= cortex_r5f_initfn
},
2015 { .name
= "cortex-a7", .initfn
= cortex_a7_initfn
},
2016 { .name
= "cortex-a8", .initfn
= cortex_a8_initfn
},
2017 { .name
= "cortex-a9", .initfn
= cortex_a9_initfn
},
2018 { .name
= "cortex-a15", .initfn
= cortex_a15_initfn
},
2019 { .name
= "ti925t", .initfn
= ti925t_initfn
},
2020 { .name
= "sa1100", .initfn
= sa1100_initfn
},
2021 { .name
= "sa1110", .initfn
= sa1110_initfn
},
2022 { .name
= "pxa250", .initfn
= pxa250_initfn
},
2023 { .name
= "pxa255", .initfn
= pxa255_initfn
},
2024 { .name
= "pxa260", .initfn
= pxa260_initfn
},
2025 { .name
= "pxa261", .initfn
= pxa261_initfn
},
2026 { .name
= "pxa262", .initfn
= pxa262_initfn
},
2027 /* "pxa270" is an alias for "pxa270-a0" */
2028 { .name
= "pxa270", .initfn
= pxa270a0_initfn
},
2029 { .name
= "pxa270-a0", .initfn
= pxa270a0_initfn
},
2030 { .name
= "pxa270-a1", .initfn
= pxa270a1_initfn
},
2031 { .name
= "pxa270-b0", .initfn
= pxa270b0_initfn
},
2032 { .name
= "pxa270-b1", .initfn
= pxa270b1_initfn
},
2033 { .name
= "pxa270-c0", .initfn
= pxa270c0_initfn
},
2034 { .name
= "pxa270-c5", .initfn
= pxa270c5_initfn
},
2035 #ifndef TARGET_AARCH64
2036 { .name
= "max", .initfn
= arm_max_initfn
},
2038 #ifdef CONFIG_USER_ONLY
2039 { .name
= "any", .initfn
= arm_max_initfn
},
2045 static Property arm_cpu_properties
[] = {
2046 DEFINE_PROP_BOOL("start-powered-off", ARMCPU
, start_powered_off
, false),
2047 DEFINE_PROP_UINT32("psci-conduit", ARMCPU
, psci_conduit
, 0),
2048 DEFINE_PROP_UINT32("midr", ARMCPU
, midr
, 0),
2049 DEFINE_PROP_UINT64("mp-affinity", ARMCPU
,
2050 mp_affinity
, ARM64_AFFINITY_INVALID
),
2051 DEFINE_PROP_INT32("node-id", ARMCPU
, node_id
, CPU_UNSET_NUMA_NODE_ID
),
2052 DEFINE_PROP_INT32("core-count", ARMCPU
, core_count
, -1),
2053 DEFINE_PROP_END_OF_LIST()
2056 #ifdef CONFIG_USER_ONLY
2057 static int arm_cpu_handle_mmu_fault(CPUState
*cs
, vaddr address
, int size
,
2058 int rw
, int mmu_idx
)
2060 ARMCPU
*cpu
= ARM_CPU(cs
);
2061 CPUARMState
*env
= &cpu
->env
;
2063 env
->exception
.vaddress
= address
;
2065 cs
->exception_index
= EXCP_PREFETCH_ABORT
;
2067 cs
->exception_index
= EXCP_DATA_ABORT
;
2073 static gchar
*arm_gdb_arch_name(CPUState
*cs
)
2075 ARMCPU
*cpu
= ARM_CPU(cs
);
2076 CPUARMState
*env
= &cpu
->env
;
2078 if (arm_feature(env
, ARM_FEATURE_IWMMXT
)) {
2079 return g_strdup("iwmmxt");
2081 return g_strdup("arm");
2084 static void arm_cpu_class_init(ObjectClass
*oc
, void *data
)
2086 ARMCPUClass
*acc
= ARM_CPU_CLASS(oc
);
2087 CPUClass
*cc
= CPU_CLASS(acc
);
2088 DeviceClass
*dc
= DEVICE_CLASS(oc
);
2090 device_class_set_parent_realize(dc
, arm_cpu_realizefn
,
2091 &acc
->parent_realize
);
2092 dc
->props
= arm_cpu_properties
;
2094 acc
->parent_reset
= cc
->reset
;
2095 cc
->reset
= arm_cpu_reset
;
2097 cc
->class_by_name
= arm_cpu_class_by_name
;
2098 cc
->has_work
= arm_cpu_has_work
;
2099 cc
->cpu_exec_interrupt
= arm_cpu_exec_interrupt
;
2100 cc
->dump_state
= arm_cpu_dump_state
;
2101 cc
->set_pc
= arm_cpu_set_pc
;
2102 cc
->gdb_read_register
= arm_cpu_gdb_read_register
;
2103 cc
->gdb_write_register
= arm_cpu_gdb_write_register
;
2104 #ifdef CONFIG_USER_ONLY
2105 cc
->handle_mmu_fault
= arm_cpu_handle_mmu_fault
;
2107 cc
->do_interrupt
= arm_cpu_do_interrupt
;
2108 cc
->do_unaligned_access
= arm_cpu_do_unaligned_access
;
2109 cc
->do_transaction_failed
= arm_cpu_do_transaction_failed
;
2110 cc
->get_phys_page_attrs_debug
= arm_cpu_get_phys_page_attrs_debug
;
2111 cc
->asidx_from_attrs
= arm_asidx_from_attrs
;
2112 cc
->vmsd
= &vmstate_arm_cpu
;
2113 cc
->virtio_is_big_endian
= arm_cpu_virtio_is_big_endian
;
2114 cc
->write_elf64_note
= arm_cpu_write_elf64_note
;
2115 cc
->write_elf32_note
= arm_cpu_write_elf32_note
;
2117 cc
->gdb_num_core_regs
= 26;
2118 cc
->gdb_core_xml_file
= "arm-core.xml";
2119 cc
->gdb_arch_name
= arm_gdb_arch_name
;
2120 cc
->gdb_get_dynamic_xml
= arm_gdb_get_dynamic_xml
;
2121 cc
->gdb_stop_before_watchpoint
= true;
2122 cc
->debug_excp_handler
= arm_debug_excp_handler
;
2123 cc
->debug_check_watchpoint
= arm_debug_check_watchpoint
;
2124 #if !defined(CONFIG_USER_ONLY)
2125 cc
->adjust_watchpoint_address
= arm_adjust_watchpoint_address
;
2128 cc
->disas_set_info
= arm_disas_set_info
;
2130 cc
->tcg_initialize
= arm_translate_init
;
2135 static void arm_host_initfn(Object
*obj
)
2137 ARMCPU
*cpu
= ARM_CPU(obj
);
2139 kvm_arm_set_cpu_features_from_host(cpu
);
2140 arm_cpu_post_init(obj
);
2143 static const TypeInfo host_arm_cpu_type_info
= {
2144 .name
= TYPE_ARM_HOST_CPU
,
2145 #ifdef TARGET_AARCH64
2146 .parent
= TYPE_AARCH64_CPU
,
2148 .parent
= TYPE_ARM_CPU
,
2150 .instance_init
= arm_host_initfn
,
2155 static void arm_cpu_instance_init(Object
*obj
)
2157 ARMCPUClass
*acc
= ARM_CPU_GET_CLASS(obj
);
2159 acc
->info
->initfn(obj
);
2160 arm_cpu_post_init(obj
);
2163 static void cpu_register_class_init(ObjectClass
*oc
, void *data
)
2165 ARMCPUClass
*acc
= ARM_CPU_CLASS(oc
);
2170 static void cpu_register(const ARMCPUInfo
*info
)
2172 TypeInfo type_info
= {
2173 .parent
= TYPE_ARM_CPU
,
2174 .instance_size
= sizeof(ARMCPU
),
2175 .instance_init
= arm_cpu_instance_init
,
2176 .class_size
= sizeof(ARMCPUClass
),
2177 .class_init
= info
->class_init
?: cpu_register_class_init
,
2178 .class_data
= (void *)info
,
2181 type_info
.name
= g_strdup_printf("%s-" TYPE_ARM_CPU
, info
->name
);
2182 type_register(&type_info
);
2183 g_free((void *)type_info
.name
);
2186 static const TypeInfo arm_cpu_type_info
= {
2187 .name
= TYPE_ARM_CPU
,
2189 .instance_size
= sizeof(ARMCPU
),
2190 .instance_init
= arm_cpu_initfn
,
2191 .instance_finalize
= arm_cpu_finalizefn
,
2193 .class_size
= sizeof(ARMCPUClass
),
2194 .class_init
= arm_cpu_class_init
,
2197 static const TypeInfo idau_interface_type_info
= {
2198 .name
= TYPE_IDAU_INTERFACE
,
2199 .parent
= TYPE_INTERFACE
,
2200 .class_size
= sizeof(IDAUInterfaceClass
),
2203 static void arm_cpu_register_types(void)
2205 const ARMCPUInfo
*info
= arm_cpus
;
2207 type_register_static(&arm_cpu_type_info
);
2208 type_register_static(&idau_interface_type_info
);
2210 while (info
->name
) {
2216 type_register_static(&host_arm_cpu_type_info
);
2220 type_init(arm_cpu_register_types
)