xref: /openbmc/qemu/target/arm/tcg/cpu32.c (revision b61af9b0)
1 /*
2  * QEMU ARM TCG-only CPUs.
3  *
4  * Copyright (c) 2012 SUSE LINUX Products GmbH
5  *
6  * This code is licensed under the GNU GPL v2 or later.
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10 
11 #include "qemu/osdep.h"
12 #include "cpu.h"
13 #include "hw/core/tcg-cpu-ops.h"
14 #include "internals.h"
15 #include "target/arm/idau.h"
16 #if !defined(CONFIG_USER_ONLY)
17 #include "hw/boards.h"
18 #endif
19 #include "cpregs.h"
20 #if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)
21 #include "hw/intc/armv7m_nvic.h"
22 #endif
23 
24 
25 /* Share AArch32 -cpu max features with AArch64. */
26 void aa32_max_features(ARMCPU *cpu)
27 {
28     uint32_t t;
29 
30     /* Add additional features supported by QEMU */
31     t = cpu->isar.id_isar5;
32     t = FIELD_DP32(t, ID_ISAR5, AES, 2);          /* FEAT_PMULL */
33     t = FIELD_DP32(t, ID_ISAR5, SHA1, 1);         /* FEAT_SHA1 */
34     t = FIELD_DP32(t, ID_ISAR5, SHA2, 1);         /* FEAT_SHA256 */
35     t = FIELD_DP32(t, ID_ISAR5, CRC32, 1);
36     t = FIELD_DP32(t, ID_ISAR5, RDM, 1);          /* FEAT_RDM */
37     t = FIELD_DP32(t, ID_ISAR5, VCMA, 1);         /* FEAT_FCMA */
38     cpu->isar.id_isar5 = t;
39 
40     t = cpu->isar.id_isar6;
41     t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1);        /* FEAT_JSCVT */
42     t = FIELD_DP32(t, ID_ISAR6, DP, 1);           /* Feat_DotProd */
43     t = FIELD_DP32(t, ID_ISAR6, FHM, 1);          /* FEAT_FHM */
44     t = FIELD_DP32(t, ID_ISAR6, SB, 1);           /* FEAT_SB */
45     t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1);      /* FEAT_SPECRES */
46     t = FIELD_DP32(t, ID_ISAR6, BF16, 1);         /* FEAT_AA32BF16 */
47     t = FIELD_DP32(t, ID_ISAR6, I8MM, 1);         /* FEAT_AA32I8MM */
48     cpu->isar.id_isar6 = t;
49 
50     t = cpu->isar.mvfr1;
51     t = FIELD_DP32(t, MVFR1, FPHP, 3);            /* FEAT_FP16 */
52     t = FIELD_DP32(t, MVFR1, SIMDHP, 2);          /* FEAT_FP16 */
53     cpu->isar.mvfr1 = t;
54 
55     t = cpu->isar.mvfr2;
56     t = FIELD_DP32(t, MVFR2, SIMDMISC, 3);        /* SIMD MaxNum */
57     t = FIELD_DP32(t, MVFR2, FPMISC, 4);          /* FP MaxNum */
58     cpu->isar.mvfr2 = t;
59 
60     t = cpu->isar.id_mmfr3;
61     t = FIELD_DP32(t, ID_MMFR3, PAN, 2);          /* FEAT_PAN2 */
62     cpu->isar.id_mmfr3 = t;
63 
64     t = cpu->isar.id_mmfr4;
65     t = FIELD_DP32(t, ID_MMFR4, HPDS, 2);         /* FEAT_HPDS2 */
66     t = FIELD_DP32(t, ID_MMFR4, AC2, 1);          /* ACTLR2, HACTLR2 */
67     t = FIELD_DP32(t, ID_MMFR4, CNP, 1);          /* FEAT_TTCNP */
68     t = FIELD_DP32(t, ID_MMFR4, XNX, 1);          /* FEAT_XNX */
69     t = FIELD_DP32(t, ID_MMFR4, EVT, 2);          /* FEAT_EVT */
70     cpu->isar.id_mmfr4 = t;
71 
72     t = cpu->isar.id_mmfr5;
73     t = FIELD_DP32(t, ID_MMFR5, ETS, 1);          /* FEAT_ETS */
74     cpu->isar.id_mmfr5 = t;
75 
76     t = cpu->isar.id_pfr0;
77     t = FIELD_DP32(t, ID_PFR0, CSV2, 2);          /* FEAT_CVS2 */
78     t = FIELD_DP32(t, ID_PFR0, DIT, 1);           /* FEAT_DIT */
79     t = FIELD_DP32(t, ID_PFR0, RAS, 1);           /* FEAT_RAS */
80     cpu->isar.id_pfr0 = t;
81 
82     t = cpu->isar.id_pfr2;
83     t = FIELD_DP32(t, ID_PFR2, CSV3, 1);          /* FEAT_CSV3 */
84     t = FIELD_DP32(t, ID_PFR2, SSBS, 1);          /* FEAT_SSBS */
85     cpu->isar.id_pfr2 = t;
86 
87     t = cpu->isar.id_dfr0;
88     t = FIELD_DP32(t, ID_DFR0, COPDBG, 9);        /* FEAT_Debugv8p4 */
89     t = FIELD_DP32(t, ID_DFR0, COPSDBG, 9);       /* FEAT_Debugv8p4 */
90     t = FIELD_DP32(t, ID_DFR0, PERFMON, 6);       /* FEAT_PMUv3p5 */
91     cpu->isar.id_dfr0 = t;
92 
93     t = cpu->isar.id_dfr1;
94     t = FIELD_DP32(t, ID_DFR1, HPMN0, 1);         /* FEAT_HPMN0 */
95     cpu->isar.id_dfr1 = t;
96 }
97 
98 /* CPU models. These are not needed for the AArch64 linux-user build. */
99 #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
100 
101 #if !defined(CONFIG_USER_ONLY)
102 static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
103 {
104     CPUClass *cc = CPU_GET_CLASS(cs);
105     ARMCPU *cpu = ARM_CPU(cs);
106     CPUARMState *env = &cpu->env;
107     bool ret = false;
108 
109     /*
110      * ARMv7-M interrupt masking works differently than -A or -R.
111      * There is no FIQ/IRQ distinction. Instead of I and F bits
112      * masking FIQ and IRQ interrupts, an exception is taken only
113      * if it is higher priority than the current execution priority
114      * (which depends on state like BASEPRI, FAULTMASK and the
115      * currently active exception).
116      */
117     if (interrupt_request & CPU_INTERRUPT_HARD
118         && (armv7m_nvic_can_take_pending_exception(env->nvic))) {
119         cs->exception_index = EXCP_IRQ;
120         cc->tcg_ops->do_interrupt(cs);
121         ret = true;
122     }
123     return ret;
124 }
125 #endif /* !CONFIG_USER_ONLY */
126 
127 static void arm926_initfn(Object *obj)
128 {
129     ARMCPU *cpu = ARM_CPU(obj);
130 
131     cpu->dtb_compatible = "arm,arm926";
132     set_feature(&cpu->env, ARM_FEATURE_V5);
133     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
134     set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN);
135     cpu->midr = 0x41069265;
136     cpu->reset_fpsid = 0x41011090;
137     cpu->ctr = 0x1dd20d2;
138     cpu->reset_sctlr = 0x00090078;
139 
140     /*
141      * ARMv5 does not have the ID_ISAR registers, but we can still
142      * set the field to indicate Jazelle support within QEMU.
143      */
144     cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1);
145     /*
146      * Similarly, we need to set MVFR0 fields to enable vfp and short vector
147      * support even though ARMv5 doesn't have this register.
148      */
149     cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
150     cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1);
151     cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1);
152 }
153 
154 static void arm946_initfn(Object *obj)
155 {
156     ARMCPU *cpu = ARM_CPU(obj);
157 
158     cpu->dtb_compatible = "arm,arm946";
159     set_feature(&cpu->env, ARM_FEATURE_V5);
160     set_feature(&cpu->env, ARM_FEATURE_PMSA);
161     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
162     cpu->midr = 0x41059461;
163     cpu->ctr = 0x0f004006;
164     cpu->reset_sctlr = 0x00000078;
165 }
166 
167 static void arm1026_initfn(Object *obj)
168 {
169     ARMCPU *cpu = ARM_CPU(obj);
170 
171     cpu->dtb_compatible = "arm,arm1026";
172     set_feature(&cpu->env, ARM_FEATURE_V5);
173     set_feature(&cpu->env, ARM_FEATURE_AUXCR);
174     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
175     set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN);
176     cpu->midr = 0x4106a262;
177     cpu->reset_fpsid = 0x410110a0;
178     cpu->ctr = 0x1dd20d2;
179     cpu->reset_sctlr = 0x00090078;
180     cpu->reset_auxcr = 1;
181 
182     /*
183      * ARMv5 does not have the ID_ISAR registers, but we can still
184      * set the field to indicate Jazelle support within QEMU.
185      */
186     cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1);
187     /*
188      * Similarly, we need to set MVFR0 fields to enable vfp and short vector
189      * support even though ARMv5 doesn't have this register.
190      */
191     cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
192     cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1);
193     cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1);
194 
195     {
196         /* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */
197         ARMCPRegInfo ifar = {
198             .name = "IFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 1,
199             .access = PL1_RW,
200             .fieldoffset = offsetof(CPUARMState, cp15.ifar_ns),
201             .resetvalue = 0
202         };
203         define_one_arm_cp_reg(cpu, &ifar);
204     }
205 }
206 
207 static void arm1136_r2_initfn(Object *obj)
208 {
209     ARMCPU *cpu = ARM_CPU(obj);
210     /*
211      * What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an
212      * older core than plain "arm1136". In particular this does not
213      * have the v6K features.
214      * These ID register values are correct for 1136 but may be wrong
215      * for 1136_r2 (in particular r0p2 does not actually implement most
216      * of the ID registers).
217      */
218 
219     cpu->dtb_compatible = "arm,arm1136";
220     set_feature(&cpu->env, ARM_FEATURE_V6);
221     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
222     set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG);
223     set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS);
224     cpu->midr = 0x4107b362;
225     cpu->reset_fpsid = 0x410120b4;
226     cpu->isar.mvfr0 = 0x11111111;
227     cpu->isar.mvfr1 = 0x00000000;
228     cpu->ctr = 0x1dd20d2;
229     cpu->reset_sctlr = 0x00050078;
230     cpu->isar.id_pfr0 = 0x111;
231     cpu->isar.id_pfr1 = 0x1;
232     cpu->isar.id_dfr0 = 0x2;
233     cpu->id_afr0 = 0x3;
234     cpu->isar.id_mmfr0 = 0x01130003;
235     cpu->isar.id_mmfr1 = 0x10030302;
236     cpu->isar.id_mmfr2 = 0x01222110;
237     cpu->isar.id_isar0 = 0x00140011;
238     cpu->isar.id_isar1 = 0x12002111;
239     cpu->isar.id_isar2 = 0x11231111;
240     cpu->isar.id_isar3 = 0x01102131;
241     cpu->isar.id_isar4 = 0x141;
242     cpu->reset_auxcr = 7;
243 }
244 
245 static void arm1136_initfn(Object *obj)
246 {
247     ARMCPU *cpu = ARM_CPU(obj);
248 
249     cpu->dtb_compatible = "arm,arm1136";
250     set_feature(&cpu->env, ARM_FEATURE_V6K);
251     set_feature(&cpu->env, ARM_FEATURE_V6);
252     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
253     set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG);
254     set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS);
255     cpu->midr = 0x4117b363;
256     cpu->reset_fpsid = 0x410120b4;
257     cpu->isar.mvfr0 = 0x11111111;
258     cpu->isar.mvfr1 = 0x00000000;
259     cpu->ctr = 0x1dd20d2;
260     cpu->reset_sctlr = 0x00050078;
261     cpu->isar.id_pfr0 = 0x111;
262     cpu->isar.id_pfr1 = 0x1;
263     cpu->isar.id_dfr0 = 0x2;
264     cpu->id_afr0 = 0x3;
265     cpu->isar.id_mmfr0 = 0x01130003;
266     cpu->isar.id_mmfr1 = 0x10030302;
267     cpu->isar.id_mmfr2 = 0x01222110;
268     cpu->isar.id_isar0 = 0x00140011;
269     cpu->isar.id_isar1 = 0x12002111;
270     cpu->isar.id_isar2 = 0x11231111;
271     cpu->isar.id_isar3 = 0x01102131;
272     cpu->isar.id_isar4 = 0x141;
273     cpu->reset_auxcr = 7;
274 }
275 
276 static void arm1176_initfn(Object *obj)
277 {
278     ARMCPU *cpu = ARM_CPU(obj);
279 
280     cpu->dtb_compatible = "arm,arm1176";
281     set_feature(&cpu->env, ARM_FEATURE_V6K);
282     set_feature(&cpu->env, ARM_FEATURE_VAPA);
283     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
284     set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG);
285     set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS);
286     set_feature(&cpu->env, ARM_FEATURE_EL3);
287     cpu->midr = 0x410fb767;
288     cpu->reset_fpsid = 0x410120b5;
289     cpu->isar.mvfr0 = 0x11111111;
290     cpu->isar.mvfr1 = 0x00000000;
291     cpu->ctr = 0x1dd20d2;
292     cpu->reset_sctlr = 0x00050078;
293     cpu->isar.id_pfr0 = 0x111;
294     cpu->isar.id_pfr1 = 0x11;
295     cpu->isar.id_dfr0 = 0x33;
296     cpu->id_afr0 = 0;
297     cpu->isar.id_mmfr0 = 0x01130003;
298     cpu->isar.id_mmfr1 = 0x10030302;
299     cpu->isar.id_mmfr2 = 0x01222100;
300     cpu->isar.id_isar0 = 0x0140011;
301     cpu->isar.id_isar1 = 0x12002111;
302     cpu->isar.id_isar2 = 0x11231121;
303     cpu->isar.id_isar3 = 0x01102131;
304     cpu->isar.id_isar4 = 0x01141;
305     cpu->reset_auxcr = 7;
306 }
307 
308 static void arm11mpcore_initfn(Object *obj)
309 {
310     ARMCPU *cpu = ARM_CPU(obj);
311 
312     cpu->dtb_compatible = "arm,arm11mpcore";
313     set_feature(&cpu->env, ARM_FEATURE_V6K);
314     set_feature(&cpu->env, ARM_FEATURE_VAPA);
315     set_feature(&cpu->env, ARM_FEATURE_MPIDR);
316     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
317     cpu->midr = 0x410fb022;
318     cpu->reset_fpsid = 0x410120b4;
319     cpu->isar.mvfr0 = 0x11111111;
320     cpu->isar.mvfr1 = 0x00000000;
321     cpu->ctr = 0x1d192992; /* 32K icache 32K dcache */
322     cpu->isar.id_pfr0 = 0x111;
323     cpu->isar.id_pfr1 = 0x1;
324     cpu->isar.id_dfr0 = 0;
325     cpu->id_afr0 = 0x2;
326     cpu->isar.id_mmfr0 = 0x01100103;
327     cpu->isar.id_mmfr1 = 0x10020302;
328     cpu->isar.id_mmfr2 = 0x01222000;
329     cpu->isar.id_isar0 = 0x00100011;
330     cpu->isar.id_isar1 = 0x12002111;
331     cpu->isar.id_isar2 = 0x11221011;
332     cpu->isar.id_isar3 = 0x01102131;
333     cpu->isar.id_isar4 = 0x141;
334     cpu->reset_auxcr = 1;
335 }
336 
337 static const ARMCPRegInfo cortexa8_cp_reginfo[] = {
338     { .name = "L2LOCKDOWN", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 0,
339       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
340     { .name = "L2AUXCR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2,
341       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
342 };
343 
344 static void cortex_a8_initfn(Object *obj)
345 {
346     ARMCPU *cpu = ARM_CPU(obj);
347 
348     cpu->dtb_compatible = "arm,cortex-a8";
349     set_feature(&cpu->env, ARM_FEATURE_V7);
350     set_feature(&cpu->env, ARM_FEATURE_NEON);
351     set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
352     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
353     set_feature(&cpu->env, ARM_FEATURE_EL3);
354     set_feature(&cpu->env, ARM_FEATURE_PMU);
355     cpu->midr = 0x410fc080;
356     cpu->reset_fpsid = 0x410330c0;
357     cpu->isar.mvfr0 = 0x11110222;
358     cpu->isar.mvfr1 = 0x00011111;
359     cpu->ctr = 0x82048004;
360     cpu->reset_sctlr = 0x00c50078;
361     cpu->isar.id_pfr0 = 0x1031;
362     cpu->isar.id_pfr1 = 0x11;
363     cpu->isar.id_dfr0 = 0x400;
364     cpu->id_afr0 = 0;
365     cpu->isar.id_mmfr0 = 0x31100003;
366     cpu->isar.id_mmfr1 = 0x20000000;
367     cpu->isar.id_mmfr2 = 0x01202000;
368     cpu->isar.id_mmfr3 = 0x11;
369     cpu->isar.id_isar0 = 0x00101111;
370     cpu->isar.id_isar1 = 0x12112111;
371     cpu->isar.id_isar2 = 0x21232031;
372     cpu->isar.id_isar3 = 0x11112131;
373     cpu->isar.id_isar4 = 0x00111142;
374     cpu->isar.dbgdidr = 0x15141000;
375     cpu->clidr = (1 << 27) | (2 << 24) | 3;
376     cpu->ccsidr[0] = 0xe007e01a; /* 16k L1 dcache. */
377     cpu->ccsidr[1] = 0x2007e01a; /* 16k L1 icache. */
378     cpu->ccsidr[2] = 0xf0000000; /* No L2 icache. */
379     cpu->reset_auxcr = 2;
380     cpu->isar.reset_pmcr_el0 = 0x41002000;
381     define_arm_cp_regs(cpu, cortexa8_cp_reginfo);
382 }
383 
384 static const ARMCPRegInfo cortexa9_cp_reginfo[] = {
385     /*
386      * power_control should be set to maximum latency. Again,
387      * default to 0 and set by private hook
388      */
389     { .name = "A9_PWRCTL", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 0,
390       .access = PL1_RW, .resetvalue = 0,
391       .fieldoffset = offsetof(CPUARMState, cp15.c15_power_control) },
392     { .name = "A9_DIAG", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 1,
393       .access = PL1_RW, .resetvalue = 0,
394       .fieldoffset = offsetof(CPUARMState, cp15.c15_diagnostic) },
395     { .name = "A9_PWRDIAG", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 2,
396       .access = PL1_RW, .resetvalue = 0,
397       .fieldoffset = offsetof(CPUARMState, cp15.c15_power_diagnostic) },
398     { .name = "NEONBUSY", .cp = 15, .crn = 15, .crm = 1, .opc1 = 0, .opc2 = 0,
399       .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
400     /* TLB lockdown control */
401     { .name = "TLB_LOCKR", .cp = 15, .crn = 15, .crm = 4, .opc1 = 5, .opc2 = 2,
402       .access = PL1_W, .resetvalue = 0, .type = ARM_CP_NOP },
403     { .name = "TLB_LOCKW", .cp = 15, .crn = 15, .crm = 4, .opc1 = 5, .opc2 = 4,
404       .access = PL1_W, .resetvalue = 0, .type = ARM_CP_NOP },
405     { .name = "TLB_VA", .cp = 15, .crn = 15, .crm = 5, .opc1 = 5, .opc2 = 2,
406       .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
407     { .name = "TLB_PA", .cp = 15, .crn = 15, .crm = 6, .opc1 = 5, .opc2 = 2,
408       .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
409     { .name = "TLB_ATTR", .cp = 15, .crn = 15, .crm = 7, .opc1 = 5, .opc2 = 2,
410       .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
411 };
412 
413 static void cortex_a9_initfn(Object *obj)
414 {
415     ARMCPU *cpu = ARM_CPU(obj);
416 
417     cpu->dtb_compatible = "arm,cortex-a9";
418     set_feature(&cpu->env, ARM_FEATURE_V7);
419     set_feature(&cpu->env, ARM_FEATURE_NEON);
420     set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
421     set_feature(&cpu->env, ARM_FEATURE_EL3);
422     set_feature(&cpu->env, ARM_FEATURE_PMU);
423     /*
424      * Note that A9 supports the MP extensions even for
425      * A9UP and single-core A9MP (which are both different
426      * and valid configurations; we don't model A9UP).
427      */
428     set_feature(&cpu->env, ARM_FEATURE_V7MP);
429     set_feature(&cpu->env, ARM_FEATURE_CBAR);
430     cpu->midr = 0x410fc090;
431     cpu->reset_fpsid = 0x41033090;
432     cpu->isar.mvfr0 = 0x11110222;
433     cpu->isar.mvfr1 = 0x01111111;
434     cpu->ctr = 0x80038003;
435     cpu->reset_sctlr = 0x00c50078;
436     cpu->isar.id_pfr0 = 0x1031;
437     cpu->isar.id_pfr1 = 0x11;
438     cpu->isar.id_dfr0 = 0x000;
439     cpu->id_afr0 = 0;
440     cpu->isar.id_mmfr0 = 0x00100103;
441     cpu->isar.id_mmfr1 = 0x20000000;
442     cpu->isar.id_mmfr2 = 0x01230000;
443     cpu->isar.id_mmfr3 = 0x00002111;
444     cpu->isar.id_isar0 = 0x00101111;
445     cpu->isar.id_isar1 = 0x13112111;
446     cpu->isar.id_isar2 = 0x21232041;
447     cpu->isar.id_isar3 = 0x11112131;
448     cpu->isar.id_isar4 = 0x00111142;
449     cpu->isar.dbgdidr = 0x35141000;
450     cpu->clidr = (1 << 27) | (1 << 24) | 3;
451     cpu->ccsidr[0] = 0xe00fe019; /* 16k L1 dcache. */
452     cpu->ccsidr[1] = 0x200fe019; /* 16k L1 icache. */
453     cpu->isar.reset_pmcr_el0 = 0x41093000;
454     define_arm_cp_regs(cpu, cortexa9_cp_reginfo);
455 }
456 
457 #ifndef CONFIG_USER_ONLY
458 static uint64_t a15_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
459 {
460     MachineState *ms = MACHINE(qdev_get_machine());
461 
462     /*
463      * Linux wants the number of processors from here.
464      * Might as well set the interrupt-controller bit too.
465      */
466     return ((ms->smp.cpus - 1) << 24) | (1 << 23);
467 }
468 #endif
469 
470 static const ARMCPRegInfo cortexa15_cp_reginfo[] = {
471 #ifndef CONFIG_USER_ONLY
472     { .name = "L2CTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2,
473       .access = PL1_RW, .resetvalue = 0, .readfn = a15_l2ctlr_read,
474       .writefn = arm_cp_write_ignore, },
475 #endif
476     { .name = "L2ECTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 3,
477       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
478 };
479 
480 static void cortex_a7_initfn(Object *obj)
481 {
482     ARMCPU *cpu = ARM_CPU(obj);
483 
484     cpu->dtb_compatible = "arm,cortex-a7";
485     set_feature(&cpu->env, ARM_FEATURE_V7VE);
486     set_feature(&cpu->env, ARM_FEATURE_NEON);
487     set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
488     set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
489     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
490     set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
491     set_feature(&cpu->env, ARM_FEATURE_EL2);
492     set_feature(&cpu->env, ARM_FEATURE_EL3);
493     set_feature(&cpu->env, ARM_FEATURE_PMU);
494     cpu->midr = 0x410fc075;
495     cpu->reset_fpsid = 0x41023075;
496     cpu->isar.mvfr0 = 0x10110222;
497     cpu->isar.mvfr1 = 0x11111111;
498     cpu->ctr = 0x84448003;
499     cpu->reset_sctlr = 0x00c50078;
500     cpu->isar.id_pfr0 = 0x00001131;
501     cpu->isar.id_pfr1 = 0x00011011;
502     cpu->isar.id_dfr0 = 0x02010555;
503     cpu->id_afr0 = 0x00000000;
504     cpu->isar.id_mmfr0 = 0x10101105;
505     cpu->isar.id_mmfr1 = 0x40000000;
506     cpu->isar.id_mmfr2 = 0x01240000;
507     cpu->isar.id_mmfr3 = 0x02102211;
508     /*
509      * a7_mpcore_r0p5_trm, page 4-4 gives 0x01101110; but
510      * table 4-41 gives 0x02101110, which includes the arm div insns.
511      */
512     cpu->isar.id_isar0 = 0x02101110;
513     cpu->isar.id_isar1 = 0x13112111;
514     cpu->isar.id_isar2 = 0x21232041;
515     cpu->isar.id_isar3 = 0x11112131;
516     cpu->isar.id_isar4 = 0x10011142;
517     cpu->isar.dbgdidr = 0x3515f005;
518     cpu->isar.dbgdevid = 0x01110f13;
519     cpu->isar.dbgdevid1 = 0x1;
520     cpu->clidr = 0x0a200023;
521     cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */
522     cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */
523     cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
524     cpu->isar.reset_pmcr_el0 = 0x41072000;
525     define_arm_cp_regs(cpu, cortexa15_cp_reginfo); /* Same as A15 */
526 }
527 
528 static void cortex_a15_initfn(Object *obj)
529 {
530     ARMCPU *cpu = ARM_CPU(obj);
531 
532     cpu->dtb_compatible = "arm,cortex-a15";
533     set_feature(&cpu->env, ARM_FEATURE_V7VE);
534     set_feature(&cpu->env, ARM_FEATURE_NEON);
535     set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
536     set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
537     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
538     set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
539     set_feature(&cpu->env, ARM_FEATURE_EL2);
540     set_feature(&cpu->env, ARM_FEATURE_EL3);
541     set_feature(&cpu->env, ARM_FEATURE_PMU);
542     /* r4p0 cpu, not requiring expensive tlb flush errata */
543     cpu->midr = 0x414fc0f0;
544     cpu->revidr = 0x0;
545     cpu->reset_fpsid = 0x410430f0;
546     cpu->isar.mvfr0 = 0x10110222;
547     cpu->isar.mvfr1 = 0x11111111;
548     cpu->ctr = 0x8444c004;
549     cpu->reset_sctlr = 0x00c50078;
550     cpu->isar.id_pfr0 = 0x00001131;
551     cpu->isar.id_pfr1 = 0x00011011;
552     cpu->isar.id_dfr0 = 0x02010555;
553     cpu->id_afr0 = 0x00000000;
554     cpu->isar.id_mmfr0 = 0x10201105;
555     cpu->isar.id_mmfr1 = 0x20000000;
556     cpu->isar.id_mmfr2 = 0x01240000;
557     cpu->isar.id_mmfr3 = 0x02102211;
558     cpu->isar.id_isar0 = 0x02101110;
559     cpu->isar.id_isar1 = 0x13112111;
560     cpu->isar.id_isar2 = 0x21232041;
561     cpu->isar.id_isar3 = 0x11112131;
562     cpu->isar.id_isar4 = 0x10011142;
563     cpu->isar.dbgdidr = 0x3515f021;
564     cpu->isar.dbgdevid = 0x01110f13;
565     cpu->isar.dbgdevid1 = 0x0;
566     cpu->clidr = 0x0a200023;
567     cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */
568     cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */
569     cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
570     cpu->isar.reset_pmcr_el0 = 0x410F3000;
571     define_arm_cp_regs(cpu, cortexa15_cp_reginfo);
572 }
573 
574 static void cortex_m0_initfn(Object *obj)
575 {
576     ARMCPU *cpu = ARM_CPU(obj);
577     set_feature(&cpu->env, ARM_FEATURE_V6);
578     set_feature(&cpu->env, ARM_FEATURE_M);
579 
580     cpu->midr = 0x410cc200;
581 
582     /*
583      * These ID register values are not guest visible, because
584      * we do not implement the Main Extension. They must be set
585      * to values corresponding to the Cortex-M0's implemented
586      * features, because QEMU generally controls its emulation
587      * by looking at ID register fields. We use the same values as
588      * for the M3.
589      */
590     cpu->isar.id_pfr0 = 0x00000030;
591     cpu->isar.id_pfr1 = 0x00000200;
592     cpu->isar.id_dfr0 = 0x00100000;
593     cpu->id_afr0 = 0x00000000;
594     cpu->isar.id_mmfr0 = 0x00000030;
595     cpu->isar.id_mmfr1 = 0x00000000;
596     cpu->isar.id_mmfr2 = 0x00000000;
597     cpu->isar.id_mmfr3 = 0x00000000;
598     cpu->isar.id_isar0 = 0x01141110;
599     cpu->isar.id_isar1 = 0x02111000;
600     cpu->isar.id_isar2 = 0x21112231;
601     cpu->isar.id_isar3 = 0x01111110;
602     cpu->isar.id_isar4 = 0x01310102;
603     cpu->isar.id_isar5 = 0x00000000;
604     cpu->isar.id_isar6 = 0x00000000;
605 }
606 
607 static void cortex_m3_initfn(Object *obj)
608 {
609     ARMCPU *cpu = ARM_CPU(obj);
610     set_feature(&cpu->env, ARM_FEATURE_V7);
611     set_feature(&cpu->env, ARM_FEATURE_M);
612     set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
613     cpu->midr = 0x410fc231;
614     cpu->pmsav7_dregion = 8;
615     cpu->isar.id_pfr0 = 0x00000030;
616     cpu->isar.id_pfr1 = 0x00000200;
617     cpu->isar.id_dfr0 = 0x00100000;
618     cpu->id_afr0 = 0x00000000;
619     cpu->isar.id_mmfr0 = 0x00000030;
620     cpu->isar.id_mmfr1 = 0x00000000;
621     cpu->isar.id_mmfr2 = 0x00000000;
622     cpu->isar.id_mmfr3 = 0x00000000;
623     cpu->isar.id_isar0 = 0x01141110;
624     cpu->isar.id_isar1 = 0x02111000;
625     cpu->isar.id_isar2 = 0x21112231;
626     cpu->isar.id_isar3 = 0x01111110;
627     cpu->isar.id_isar4 = 0x01310102;
628     cpu->isar.id_isar5 = 0x00000000;
629     cpu->isar.id_isar6 = 0x00000000;
630 }
631 
632 static void cortex_m4_initfn(Object *obj)
633 {
634     ARMCPU *cpu = ARM_CPU(obj);
635 
636     set_feature(&cpu->env, ARM_FEATURE_V7);
637     set_feature(&cpu->env, ARM_FEATURE_M);
638     set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
639     set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
640     cpu->midr = 0x410fc240; /* r0p0 */
641     cpu->pmsav7_dregion = 8;
642     cpu->isar.mvfr0 = 0x10110021;
643     cpu->isar.mvfr1 = 0x11000011;
644     cpu->isar.mvfr2 = 0x00000000;
645     cpu->isar.id_pfr0 = 0x00000030;
646     cpu->isar.id_pfr1 = 0x00000200;
647     cpu->isar.id_dfr0 = 0x00100000;
648     cpu->id_afr0 = 0x00000000;
649     cpu->isar.id_mmfr0 = 0x00000030;
650     cpu->isar.id_mmfr1 = 0x00000000;
651     cpu->isar.id_mmfr2 = 0x00000000;
652     cpu->isar.id_mmfr3 = 0x00000000;
653     cpu->isar.id_isar0 = 0x01141110;
654     cpu->isar.id_isar1 = 0x02111000;
655     cpu->isar.id_isar2 = 0x21112231;
656     cpu->isar.id_isar3 = 0x01111110;
657     cpu->isar.id_isar4 = 0x01310102;
658     cpu->isar.id_isar5 = 0x00000000;
659     cpu->isar.id_isar6 = 0x00000000;
660 }
661 
662 static void cortex_m7_initfn(Object *obj)
663 {
664     ARMCPU *cpu = ARM_CPU(obj);
665 
666     set_feature(&cpu->env, ARM_FEATURE_V7);
667     set_feature(&cpu->env, ARM_FEATURE_M);
668     set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
669     set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
670     cpu->midr = 0x411fc272; /* r1p2 */
671     cpu->pmsav7_dregion = 8;
672     cpu->isar.mvfr0 = 0x10110221;
673     cpu->isar.mvfr1 = 0x12000011;
674     cpu->isar.mvfr2 = 0x00000040;
675     cpu->isar.id_pfr0 = 0x00000030;
676     cpu->isar.id_pfr1 = 0x00000200;
677     cpu->isar.id_dfr0 = 0x00100000;
678     cpu->id_afr0 = 0x00000000;
679     cpu->isar.id_mmfr0 = 0x00100030;
680     cpu->isar.id_mmfr1 = 0x00000000;
681     cpu->isar.id_mmfr2 = 0x01000000;
682     cpu->isar.id_mmfr3 = 0x00000000;
683     cpu->isar.id_isar0 = 0x01101110;
684     cpu->isar.id_isar1 = 0x02112000;
685     cpu->isar.id_isar2 = 0x20232231;
686     cpu->isar.id_isar3 = 0x01111131;
687     cpu->isar.id_isar4 = 0x01310132;
688     cpu->isar.id_isar5 = 0x00000000;
689     cpu->isar.id_isar6 = 0x00000000;
690 }
691 
692 static void cortex_m33_initfn(Object *obj)
693 {
694     ARMCPU *cpu = ARM_CPU(obj);
695 
696     set_feature(&cpu->env, ARM_FEATURE_V8);
697     set_feature(&cpu->env, ARM_FEATURE_M);
698     set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
699     set_feature(&cpu->env, ARM_FEATURE_M_SECURITY);
700     set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
701     cpu->midr = 0x410fd213; /* r0p3 */
702     cpu->pmsav7_dregion = 16;
703     cpu->sau_sregion = 8;
704     cpu->isar.mvfr0 = 0x10110021;
705     cpu->isar.mvfr1 = 0x11000011;
706     cpu->isar.mvfr2 = 0x00000040;
707     cpu->isar.id_pfr0 = 0x00000030;
708     cpu->isar.id_pfr1 = 0x00000210;
709     cpu->isar.id_dfr0 = 0x00200000;
710     cpu->id_afr0 = 0x00000000;
711     cpu->isar.id_mmfr0 = 0x00101F40;
712     cpu->isar.id_mmfr1 = 0x00000000;
713     cpu->isar.id_mmfr2 = 0x01000000;
714     cpu->isar.id_mmfr3 = 0x00000000;
715     cpu->isar.id_isar0 = 0x01101110;
716     cpu->isar.id_isar1 = 0x02212000;
717     cpu->isar.id_isar2 = 0x20232232;
718     cpu->isar.id_isar3 = 0x01111131;
719     cpu->isar.id_isar4 = 0x01310132;
720     cpu->isar.id_isar5 = 0x00000000;
721     cpu->isar.id_isar6 = 0x00000000;
722     cpu->clidr = 0x00000000;
723     cpu->ctr = 0x8000c000;
724 }
725 
726 static void cortex_m55_initfn(Object *obj)
727 {
728     ARMCPU *cpu = ARM_CPU(obj);
729 
730     set_feature(&cpu->env, ARM_FEATURE_V8);
731     set_feature(&cpu->env, ARM_FEATURE_V8_1M);
732     set_feature(&cpu->env, ARM_FEATURE_M);
733     set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
734     set_feature(&cpu->env, ARM_FEATURE_M_SECURITY);
735     set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
736     cpu->midr = 0x410fd221; /* r0p1 */
737     cpu->revidr = 0;
738     cpu->pmsav7_dregion = 16;
739     cpu->sau_sregion = 8;
740     /* These are the MVFR* values for the FPU + full MVE configuration */
741     cpu->isar.mvfr0 = 0x10110221;
742     cpu->isar.mvfr1 = 0x12100211;
743     cpu->isar.mvfr2 = 0x00000040;
744     cpu->isar.id_pfr0 = 0x20000030;
745     cpu->isar.id_pfr1 = 0x00000230;
746     cpu->isar.id_dfr0 = 0x10200000;
747     cpu->id_afr0 = 0x00000000;
748     cpu->isar.id_mmfr0 = 0x00111040;
749     cpu->isar.id_mmfr1 = 0x00000000;
750     cpu->isar.id_mmfr2 = 0x01000000;
751     cpu->isar.id_mmfr3 = 0x00000011;
752     cpu->isar.id_isar0 = 0x01103110;
753     cpu->isar.id_isar1 = 0x02212000;
754     cpu->isar.id_isar2 = 0x20232232;
755     cpu->isar.id_isar3 = 0x01111131;
756     cpu->isar.id_isar4 = 0x01310132;
757     cpu->isar.id_isar5 = 0x00000000;
758     cpu->isar.id_isar6 = 0x00000000;
759     cpu->clidr = 0x00000000; /* caches not implemented */
760     cpu->ctr = 0x8303c003;
761 }
762 
763 static const ARMCPRegInfo cortexr5_cp_reginfo[] = {
764     /* Dummy the TCM region regs for the moment */
765     { .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0,
766       .access = PL1_RW, .type = ARM_CP_CONST },
767     { .name = "BTCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 1,
768       .access = PL1_RW, .type = ARM_CP_CONST },
769     { .name = "DCACHE_INVAL", .cp = 15, .opc1 = 0, .crn = 15, .crm = 5,
770       .opc2 = 0, .access = PL1_W, .type = ARM_CP_NOP },
771 };
772 
773 static void cortex_r5_initfn(Object *obj)
774 {
775     ARMCPU *cpu = ARM_CPU(obj);
776 
777     set_feature(&cpu->env, ARM_FEATURE_V7);
778     set_feature(&cpu->env, ARM_FEATURE_V7MP);
779     set_feature(&cpu->env, ARM_FEATURE_PMSA);
780     set_feature(&cpu->env, ARM_FEATURE_PMU);
781     cpu->midr = 0x411fc153; /* r1p3 */
782     cpu->isar.id_pfr0 = 0x0131;
783     cpu->isar.id_pfr1 = 0x001;
784     cpu->isar.id_dfr0 = 0x010400;
785     cpu->id_afr0 = 0x0;
786     cpu->isar.id_mmfr0 = 0x0210030;
787     cpu->isar.id_mmfr1 = 0x00000000;
788     cpu->isar.id_mmfr2 = 0x01200000;
789     cpu->isar.id_mmfr3 = 0x0211;
790     cpu->isar.id_isar0 = 0x02101111;
791     cpu->isar.id_isar1 = 0x13112111;
792     cpu->isar.id_isar2 = 0x21232141;
793     cpu->isar.id_isar3 = 0x01112131;
794     cpu->isar.id_isar4 = 0x0010142;
795     cpu->isar.id_isar5 = 0x0;
796     cpu->isar.id_isar6 = 0x0;
797     cpu->mp_is_up = true;
798     cpu->pmsav7_dregion = 16;
799     cpu->isar.reset_pmcr_el0 = 0x41151800;
800     define_arm_cp_regs(cpu, cortexr5_cp_reginfo);
801 }
802 
803 static const ARMCPRegInfo cortex_r52_cp_reginfo[] = {
804     { .name = "CPUACTLR", .cp = 15, .opc1 = 0, .crm = 15,
805       .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
806     { .name = "IMP_ATCMREGIONR",
807       .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0,
808       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
809     { .name = "IMP_BTCMREGIONR",
810       .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 1,
811       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
812     { .name = "IMP_CTCMREGIONR",
813       .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 2,
814       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
815     { .name = "IMP_CSCTLR",
816       .cp = 15, .opc1 = 1, .crn = 9, .crm = 1, .opc2 = 0,
817       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
818     { .name = "IMP_BPCTLR",
819       .cp = 15, .opc1 = 1, .crn = 9, .crm = 1, .opc2 = 1,
820       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
821     { .name = "IMP_MEMPROTCLR",
822       .cp = 15, .opc1 = 1, .crn = 9, .crm = 1, .opc2 = 2,
823       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
824     { .name = "IMP_SLAVEPCTLR",
825       .cp = 15, .opc1 = 0, .crn = 11, .crm = 0, .opc2 = 0,
826       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
827     { .name = "IMP_PERIPHREGIONR",
828       .cp = 15, .opc1 = 0, .crn = 15, .crm = 0, .opc2 = 0,
829       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
830     { .name = "IMP_FLASHIFREGIONR",
831       .cp = 15, .opc1 = 0, .crn = 15, .crm = 0, .opc2 = 1,
832       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
833     { .name = "IMP_BUILDOPTR",
834       .cp = 15, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 0,
835       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
836     { .name = "IMP_PINOPTR",
837       .cp = 15, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 7,
838       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
839     { .name = "IMP_QOSR",
840       .cp = 15, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 1,
841       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
842     { .name = "IMP_BUSTIMEOUTR",
843       .cp = 15, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 2,
844       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
845     { .name = "IMP_INTMONR",
846       .cp = 15, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 4,
847       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
848     { .name = "IMP_ICERR0",
849       .cp = 15, .opc1 = 2, .crn = 15, .crm = 0, .opc2 = 0,
850       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
851     { .name = "IMP_ICERR1",
852       .cp = 15, .opc1 = 2, .crn = 15, .crm = 0, .opc2 = 1,
853       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
854     { .name = "IMP_DCERR0",
855       .cp = 15, .opc1 = 2, .crn = 15, .crm = 1, .opc2 = 0,
856       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
857     { .name = "IMP_DCERR1",
858       .cp = 15, .opc1 = 2, .crn = 15, .crm = 1, .opc2 = 1,
859       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
860     { .name = "IMP_TCMERR0",
861       .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 0,
862       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
863     { .name = "IMP_TCMERR1",
864       .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 1,
865       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
866     { .name = "IMP_TCMSYNDR0",
867       .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 2,
868       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
869     { .name = "IMP_TCMSYNDR1",
870       .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 3,
871       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
872     { .name = "IMP_FLASHERR0",
873       .cp = 15, .opc1 = 2, .crn = 15, .crm = 3, .opc2 = 0,
874       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
875     { .name = "IMP_FLASHERR1",
876       .cp = 15, .opc1 = 2, .crn = 15, .crm = 3, .opc2 = 1,
877       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
878     { .name = "IMP_CDBGDR0",
879       .cp = 15, .opc1 = 3, .crn = 15, .crm = 0, .opc2 = 0,
880       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
881     { .name = "IMP_CBDGBR1",
882       .cp = 15, .opc1 = 3, .crn = 15, .crm = 0, .opc2 = 1,
883       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
884     { .name = "IMP_TESTR0",
885       .cp = 15, .opc1 = 4, .crn = 15, .crm = 0, .opc2 = 0,
886       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
887     { .name = "IMP_TESTR1",
888       .cp = 15, .opc1 = 4, .crn = 15, .crm = 0, .opc2 = 1,
889       .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
890     { .name = "IMP_CDBGDCI",
891       .cp = 15, .opc1 = 0, .crn = 15, .crm = 15, .opc2 = 0,
892       .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
893     { .name = "IMP_CDBGDCT",
894       .cp = 15, .opc1 = 3, .crn = 15, .crm = 2, .opc2 = 0,
895       .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
896     { .name = "IMP_CDBGICT",
897       .cp = 15, .opc1 = 3, .crn = 15, .crm = 2, .opc2 = 1,
898       .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
899     { .name = "IMP_CDBGDCD",
900       .cp = 15, .opc1 = 3, .crn = 15, .crm = 4, .opc2 = 0,
901       .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
902     { .name = "IMP_CDBGICD",
903       .cp = 15, .opc1 = 3, .crn = 15, .crm = 4, .opc2 = 1,
904       .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
905 };
906 
907 
908 static void cortex_r52_initfn(Object *obj)
909 {
910     ARMCPU *cpu = ARM_CPU(obj);
911 
912     set_feature(&cpu->env, ARM_FEATURE_V8);
913     set_feature(&cpu->env, ARM_FEATURE_EL2);
914     set_feature(&cpu->env, ARM_FEATURE_PMSA);
915     set_feature(&cpu->env, ARM_FEATURE_NEON);
916     set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
917     set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
918     set_feature(&cpu->env, ARM_FEATURE_AUXCR);
919     cpu->midr = 0x411fd133; /* r1p3 */
920     cpu->revidr = 0x00000000;
921     cpu->reset_fpsid = 0x41034023;
922     cpu->isar.mvfr0 = 0x10110222;
923     cpu->isar.mvfr1 = 0x12111111;
924     cpu->isar.mvfr2 = 0x00000043;
925     cpu->ctr = 0x8144c004;
926     cpu->reset_sctlr = 0x30c50838;
927     cpu->isar.id_pfr0 = 0x00000131;
928     cpu->isar.id_pfr1 = 0x10111001;
929     cpu->isar.id_dfr0 = 0x03010006;
930     cpu->id_afr0 = 0x00000000;
931     cpu->isar.id_mmfr0 = 0x00211040;
932     cpu->isar.id_mmfr1 = 0x40000000;
933     cpu->isar.id_mmfr2 = 0x01200000;
934     cpu->isar.id_mmfr3 = 0xf0102211;
935     cpu->isar.id_mmfr4 = 0x00000010;
936     cpu->isar.id_isar0 = 0x02101110;
937     cpu->isar.id_isar1 = 0x13112111;
938     cpu->isar.id_isar2 = 0x21232142;
939     cpu->isar.id_isar3 = 0x01112131;
940     cpu->isar.id_isar4 = 0x00010142;
941     cpu->isar.id_isar5 = 0x00010001;
942     cpu->isar.dbgdidr = 0x77168000;
943     cpu->clidr = (1 << 27) | (1 << 24) | 0x3;
944     cpu->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */
945     cpu->ccsidr[1] = 0x201fe00a; /* 32KB L1 icache */
946 
947     cpu->pmsav7_dregion = 16;
948     cpu->pmsav8r_hdregion = 16;
949 
950     define_arm_cp_regs(cpu, cortex_r52_cp_reginfo);
951 }
952 
953 static void cortex_r5f_initfn(Object *obj)
954 {
955     ARMCPU *cpu = ARM_CPU(obj);
956 
957     cortex_r5_initfn(obj);
958     cpu->isar.mvfr0 = 0x10110221;
959     cpu->isar.mvfr1 = 0x00000011;
960 }
961 
962 static void ti925t_initfn(Object *obj)
963 {
964     ARMCPU *cpu = ARM_CPU(obj);
965     set_feature(&cpu->env, ARM_FEATURE_V4T);
966     set_feature(&cpu->env, ARM_FEATURE_OMAPCP);
967     cpu->midr = ARM_CPUID_TI925T;
968     cpu->ctr = 0x5109149;
969     cpu->reset_sctlr = 0x00000070;
970 }
971 
972 static void sa1100_initfn(Object *obj)
973 {
974     ARMCPU *cpu = ARM_CPU(obj);
975 
976     cpu->dtb_compatible = "intel,sa1100";
977     set_feature(&cpu->env, ARM_FEATURE_STRONGARM);
978     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
979     cpu->midr = 0x4401A11B;
980     cpu->reset_sctlr = 0x00000070;
981 }
982 
983 static void sa1110_initfn(Object *obj)
984 {
985     ARMCPU *cpu = ARM_CPU(obj);
986     set_feature(&cpu->env, ARM_FEATURE_STRONGARM);
987     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
988     cpu->midr = 0x6901B119;
989     cpu->reset_sctlr = 0x00000070;
990 }
991 
992 static void pxa250_initfn(Object *obj)
993 {
994     ARMCPU *cpu = ARM_CPU(obj);
995 
996     cpu->dtb_compatible = "marvell,xscale";
997     set_feature(&cpu->env, ARM_FEATURE_V5);
998     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
999     cpu->midr = 0x69052100;
1000     cpu->ctr = 0xd172172;
1001     cpu->reset_sctlr = 0x00000078;
1002 }
1003 
1004 static void pxa255_initfn(Object *obj)
1005 {
1006     ARMCPU *cpu = ARM_CPU(obj);
1007 
1008     cpu->dtb_compatible = "marvell,xscale";
1009     set_feature(&cpu->env, ARM_FEATURE_V5);
1010     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1011     cpu->midr = 0x69052d00;
1012     cpu->ctr = 0xd172172;
1013     cpu->reset_sctlr = 0x00000078;
1014 }
1015 
1016 static void pxa260_initfn(Object *obj)
1017 {
1018     ARMCPU *cpu = ARM_CPU(obj);
1019 
1020     cpu->dtb_compatible = "marvell,xscale";
1021     set_feature(&cpu->env, ARM_FEATURE_V5);
1022     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1023     cpu->midr = 0x69052903;
1024     cpu->ctr = 0xd172172;
1025     cpu->reset_sctlr = 0x00000078;
1026 }
1027 
1028 static void pxa261_initfn(Object *obj)
1029 {
1030     ARMCPU *cpu = ARM_CPU(obj);
1031 
1032     cpu->dtb_compatible = "marvell,xscale";
1033     set_feature(&cpu->env, ARM_FEATURE_V5);
1034     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1035     cpu->midr = 0x69052d05;
1036     cpu->ctr = 0xd172172;
1037     cpu->reset_sctlr = 0x00000078;
1038 }
1039 
1040 static void pxa262_initfn(Object *obj)
1041 {
1042     ARMCPU *cpu = ARM_CPU(obj);
1043 
1044     cpu->dtb_compatible = "marvell,xscale";
1045     set_feature(&cpu->env, ARM_FEATURE_V5);
1046     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1047     cpu->midr = 0x69052d06;
1048     cpu->ctr = 0xd172172;
1049     cpu->reset_sctlr = 0x00000078;
1050 }
1051 
1052 static void pxa270a0_initfn(Object *obj)
1053 {
1054     ARMCPU *cpu = ARM_CPU(obj);
1055 
1056     cpu->dtb_compatible = "marvell,xscale";
1057     set_feature(&cpu->env, ARM_FEATURE_V5);
1058     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1059     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
1060     cpu->midr = 0x69054110;
1061     cpu->ctr = 0xd172172;
1062     cpu->reset_sctlr = 0x00000078;
1063 }
1064 
1065 static void pxa270a1_initfn(Object *obj)
1066 {
1067     ARMCPU *cpu = ARM_CPU(obj);
1068 
1069     cpu->dtb_compatible = "marvell,xscale";
1070     set_feature(&cpu->env, ARM_FEATURE_V5);
1071     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1072     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
1073     cpu->midr = 0x69054111;
1074     cpu->ctr = 0xd172172;
1075     cpu->reset_sctlr = 0x00000078;
1076 }
1077 
1078 static void pxa270b0_initfn(Object *obj)
1079 {
1080     ARMCPU *cpu = ARM_CPU(obj);
1081 
1082     cpu->dtb_compatible = "marvell,xscale";
1083     set_feature(&cpu->env, ARM_FEATURE_V5);
1084     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1085     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
1086     cpu->midr = 0x69054112;
1087     cpu->ctr = 0xd172172;
1088     cpu->reset_sctlr = 0x00000078;
1089 }
1090 
1091 static void pxa270b1_initfn(Object *obj)
1092 {
1093     ARMCPU *cpu = ARM_CPU(obj);
1094 
1095     cpu->dtb_compatible = "marvell,xscale";
1096     set_feature(&cpu->env, ARM_FEATURE_V5);
1097     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1098     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
1099     cpu->midr = 0x69054113;
1100     cpu->ctr = 0xd172172;
1101     cpu->reset_sctlr = 0x00000078;
1102 }
1103 
1104 static void pxa270c0_initfn(Object *obj)
1105 {
1106     ARMCPU *cpu = ARM_CPU(obj);
1107 
1108     cpu->dtb_compatible = "marvell,xscale";
1109     set_feature(&cpu->env, ARM_FEATURE_V5);
1110     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1111     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
1112     cpu->midr = 0x69054114;
1113     cpu->ctr = 0xd172172;
1114     cpu->reset_sctlr = 0x00000078;
1115 }
1116 
1117 static void pxa270c5_initfn(Object *obj)
1118 {
1119     ARMCPU *cpu = ARM_CPU(obj);
1120 
1121     cpu->dtb_compatible = "marvell,xscale";
1122     set_feature(&cpu->env, ARM_FEATURE_V5);
1123     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1124     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
1125     cpu->midr = 0x69054117;
1126     cpu->ctr = 0xd172172;
1127     cpu->reset_sctlr = 0x00000078;
1128 }
1129 
1130 static const TCGCPUOps arm_v7m_tcg_ops = {
1131     .initialize = arm_translate_init,
1132     .synchronize_from_tb = arm_cpu_synchronize_from_tb,
1133     .debug_excp_handler = arm_debug_excp_handler,
1134     .restore_state_to_opc = arm_restore_state_to_opc,
1135 
1136 #ifdef CONFIG_USER_ONLY
1137     .record_sigsegv = arm_cpu_record_sigsegv,
1138     .record_sigbus = arm_cpu_record_sigbus,
1139 #else
1140     .tlb_fill = arm_cpu_tlb_fill,
1141     .cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt,
1142     .do_interrupt = arm_v7m_cpu_do_interrupt,
1143     .do_transaction_failed = arm_cpu_do_transaction_failed,
1144     .do_unaligned_access = arm_cpu_do_unaligned_access,
1145     .adjust_watchpoint_address = arm_adjust_watchpoint_address,
1146     .debug_check_watchpoint = arm_debug_check_watchpoint,
1147     .debug_check_breakpoint = arm_debug_check_breakpoint,
1148 #endif /* !CONFIG_USER_ONLY */
1149 };
1150 
1151 static void arm_v7m_class_init(ObjectClass *oc, void *data)
1152 {
1153     ARMCPUClass *acc = ARM_CPU_CLASS(oc);
1154     CPUClass *cc = CPU_CLASS(oc);
1155 
1156     acc->info = data;
1157     cc->tcg_ops = &arm_v7m_tcg_ops;
1158     cc->gdb_core_xml_file = "arm-m-profile.xml";
1159 }
1160 
1161 #ifndef TARGET_AARCH64
1162 /*
1163  * -cpu max: a CPU with as many features enabled as our emulation supports.
1164  * The version of '-cpu max' for qemu-system-aarch64 is defined in cpu64.c;
1165  * this only needs to handle 32 bits, and need not care about KVM.
1166  */
1167 static void arm_max_initfn(Object *obj)
1168 {
1169     ARMCPU *cpu = ARM_CPU(obj);
1170 
1171     /* aarch64_a57_initfn, advertising none of the aarch64 features */
1172     cpu->dtb_compatible = "arm,cortex-a57";
1173     set_feature(&cpu->env, ARM_FEATURE_V8);
1174     set_feature(&cpu->env, ARM_FEATURE_NEON);
1175     set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
1176     set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
1177     set_feature(&cpu->env, ARM_FEATURE_EL2);
1178     set_feature(&cpu->env, ARM_FEATURE_EL3);
1179     set_feature(&cpu->env, ARM_FEATURE_PMU);
1180     cpu->midr = 0x411fd070;
1181     cpu->revidr = 0x00000000;
1182     cpu->reset_fpsid = 0x41034070;
1183     cpu->isar.mvfr0 = 0x10110222;
1184     cpu->isar.mvfr1 = 0x12111111;
1185     cpu->isar.mvfr2 = 0x00000043;
1186     cpu->ctr = 0x8444c004;
1187     cpu->reset_sctlr = 0x00c50838;
1188     cpu->isar.id_pfr0 = 0x00000131;
1189     cpu->isar.id_pfr1 = 0x00011011;
1190     cpu->isar.id_dfr0 = 0x03010066;
1191     cpu->id_afr0 = 0x00000000;
1192     cpu->isar.id_mmfr0 = 0x10101105;
1193     cpu->isar.id_mmfr1 = 0x40000000;
1194     cpu->isar.id_mmfr2 = 0x01260000;
1195     cpu->isar.id_mmfr3 = 0x02102211;
1196     cpu->isar.id_isar0 = 0x02101110;
1197     cpu->isar.id_isar1 = 0x13112111;
1198     cpu->isar.id_isar2 = 0x21232042;
1199     cpu->isar.id_isar3 = 0x01112131;
1200     cpu->isar.id_isar4 = 0x00011142;
1201     cpu->isar.id_isar5 = 0x00011121;
1202     cpu->isar.id_isar6 = 0;
1203     cpu->isar.dbgdidr = 0x3516d000;
1204     cpu->isar.dbgdevid = 0x00110f13;
1205     cpu->isar.dbgdevid1 = 0x2;
1206     cpu->isar.reset_pmcr_el0 = 0x41013000;
1207     cpu->clidr = 0x0a200023;
1208     cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */
1209     cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */
1210     cpu->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */
1211     define_cortex_a72_a57_a53_cp_reginfo(cpu);
1212 
1213     aa32_max_features(cpu);
1214 
1215 #ifdef CONFIG_USER_ONLY
1216     /*
1217      * Break with true ARMv8 and add back old-style VFP short-vector support.
1218      * Only do this for user-mode, where -cpu max is the default, so that
1219      * older v6 and v7 programs are more likely to work without adjustment.
1220      */
1221     cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
1222 #endif
1223 }
1224 #endif /* !TARGET_AARCH64 */
1225 
1226 static const ARMCPUInfo arm_tcg_cpus[] = {
1227     { .name = "arm926",      .initfn = arm926_initfn },
1228     { .name = "arm946",      .initfn = arm946_initfn },
1229     { .name = "arm1026",     .initfn = arm1026_initfn },
1230     /*
1231      * What QEMU calls "arm1136-r2" is actually the 1136 r0p2, i.e. an
1232      * older core than plain "arm1136". In particular this does not
1233      * have the v6K features.
1234      */
1235     { .name = "arm1136-r2",  .initfn = arm1136_r2_initfn },
1236     { .name = "arm1136",     .initfn = arm1136_initfn },
1237     { .name = "arm1176",     .initfn = arm1176_initfn },
1238     { .name = "arm11mpcore", .initfn = arm11mpcore_initfn },
1239     { .name = "cortex-a7",   .initfn = cortex_a7_initfn },
1240     { .name = "cortex-a8",   .initfn = cortex_a8_initfn },
1241     { .name = "cortex-a9",   .initfn = cortex_a9_initfn },
1242     { .name = "cortex-a15",  .initfn = cortex_a15_initfn },
1243     { .name = "cortex-m0",   .initfn = cortex_m0_initfn,
1244                              .class_init = arm_v7m_class_init },
1245     { .name = "cortex-m3",   .initfn = cortex_m3_initfn,
1246                              .class_init = arm_v7m_class_init },
1247     { .name = "cortex-m4",   .initfn = cortex_m4_initfn,
1248                              .class_init = arm_v7m_class_init },
1249     { .name = "cortex-m7",   .initfn = cortex_m7_initfn,
1250                              .class_init = arm_v7m_class_init },
1251     { .name = "cortex-m33",  .initfn = cortex_m33_initfn,
1252                              .class_init = arm_v7m_class_init },
1253     { .name = "cortex-m55",  .initfn = cortex_m55_initfn,
1254                              .class_init = arm_v7m_class_init },
1255     { .name = "cortex-r5",   .initfn = cortex_r5_initfn },
1256     { .name = "cortex-r5f",  .initfn = cortex_r5f_initfn },
1257     { .name = "cortex-r52",  .initfn = cortex_r52_initfn },
1258     { .name = "ti925t",      .initfn = ti925t_initfn },
1259     { .name = "sa1100",      .initfn = sa1100_initfn },
1260     { .name = "sa1110",      .initfn = sa1110_initfn },
1261     { .name = "pxa250",      .initfn = pxa250_initfn },
1262     { .name = "pxa255",      .initfn = pxa255_initfn },
1263     { .name = "pxa260",      .initfn = pxa260_initfn },
1264     { .name = "pxa261",      .initfn = pxa261_initfn },
1265     { .name = "pxa262",      .initfn = pxa262_initfn },
1266     /* "pxa270" is an alias for "pxa270-a0" */
1267     { .name = "pxa270",      .initfn = pxa270a0_initfn },
1268     { .name = "pxa270-a0",   .initfn = pxa270a0_initfn },
1269     { .name = "pxa270-a1",   .initfn = pxa270a1_initfn },
1270     { .name = "pxa270-b0",   .initfn = pxa270b0_initfn },
1271     { .name = "pxa270-b1",   .initfn = pxa270b1_initfn },
1272     { .name = "pxa270-c0",   .initfn = pxa270c0_initfn },
1273     { .name = "pxa270-c5",   .initfn = pxa270c5_initfn },
1274 #ifndef TARGET_AARCH64
1275     { .name = "max",         .initfn = arm_max_initfn },
1276 #endif
1277 #ifdef CONFIG_USER_ONLY
1278     { .name = "any",         .initfn = arm_max_initfn },
1279 #endif
1280 };
1281 
1282 static const TypeInfo idau_interface_type_info = {
1283     .name = TYPE_IDAU_INTERFACE,
1284     .parent = TYPE_INTERFACE,
1285     .class_size = sizeof(IDAUInterfaceClass),
1286 };
1287 
1288 static void arm_tcg_cpu_register_types(void)
1289 {
1290     size_t i;
1291 
1292     type_register_static(&idau_interface_type_info);
1293     for (i = 0; i < ARRAY_SIZE(arm_tcg_cpus); ++i) {
1294         arm_cpu_register(&arm_tcg_cpus[i]);
1295     }
1296 }
1297 
1298 type_init(arm_tcg_cpu_register_types)
1299 
1300 #endif /* !CONFIG_USER_ONLY || !TARGET_AARCH64 */
1301