xref: /openbmc/qemu/target/arm/tcg/cpu32.c (revision 26ea2789)
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     cpu->midr = 0x410fc080;
355     cpu->reset_fpsid = 0x410330c0;
356     cpu->isar.mvfr0 = 0x11110222;
357     cpu->isar.mvfr1 = 0x00011111;
358     cpu->ctr = 0x82048004;
359     cpu->reset_sctlr = 0x00c50078;
360     cpu->isar.id_pfr0 = 0x1031;
361     cpu->isar.id_pfr1 = 0x11;
362     cpu->isar.id_dfr0 = 0x400;
363     cpu->id_afr0 = 0;
364     cpu->isar.id_mmfr0 = 0x31100003;
365     cpu->isar.id_mmfr1 = 0x20000000;
366     cpu->isar.id_mmfr2 = 0x01202000;
367     cpu->isar.id_mmfr3 = 0x11;
368     cpu->isar.id_isar0 = 0x00101111;
369     cpu->isar.id_isar1 = 0x12112111;
370     cpu->isar.id_isar2 = 0x21232031;
371     cpu->isar.id_isar3 = 0x11112131;
372     cpu->isar.id_isar4 = 0x00111142;
373     cpu->isar.dbgdidr = 0x15141000;
374     cpu->clidr = (1 << 27) | (2 << 24) | 3;
375     cpu->ccsidr[0] = 0xe007e01a; /* 16k L1 dcache. */
376     cpu->ccsidr[1] = 0x2007e01a; /* 16k L1 icache. */
377     cpu->ccsidr[2] = 0xf0000000; /* No L2 icache. */
378     cpu->reset_auxcr = 2;
379     cpu->isar.reset_pmcr_el0 = 0x41002000;
380     define_arm_cp_regs(cpu, cortexa8_cp_reginfo);
381 }
382 
383 static const ARMCPRegInfo cortexa9_cp_reginfo[] = {
384     /*
385      * power_control should be set to maximum latency. Again,
386      * default to 0 and set by private hook
387      */
388     { .name = "A9_PWRCTL", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 0,
389       .access = PL1_RW, .resetvalue = 0,
390       .fieldoffset = offsetof(CPUARMState, cp15.c15_power_control) },
391     { .name = "A9_DIAG", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 1,
392       .access = PL1_RW, .resetvalue = 0,
393       .fieldoffset = offsetof(CPUARMState, cp15.c15_diagnostic) },
394     { .name = "A9_PWRDIAG", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 2,
395       .access = PL1_RW, .resetvalue = 0,
396       .fieldoffset = offsetof(CPUARMState, cp15.c15_power_diagnostic) },
397     { .name = "NEONBUSY", .cp = 15, .crn = 15, .crm = 1, .opc1 = 0, .opc2 = 0,
398       .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
399     /* TLB lockdown control */
400     { .name = "TLB_LOCKR", .cp = 15, .crn = 15, .crm = 4, .opc1 = 5, .opc2 = 2,
401       .access = PL1_W, .resetvalue = 0, .type = ARM_CP_NOP },
402     { .name = "TLB_LOCKW", .cp = 15, .crn = 15, .crm = 4, .opc1 = 5, .opc2 = 4,
403       .access = PL1_W, .resetvalue = 0, .type = ARM_CP_NOP },
404     { .name = "TLB_VA", .cp = 15, .crn = 15, .crm = 5, .opc1 = 5, .opc2 = 2,
405       .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
406     { .name = "TLB_PA", .cp = 15, .crn = 15, .crm = 6, .opc1 = 5, .opc2 = 2,
407       .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
408     { .name = "TLB_ATTR", .cp = 15, .crn = 15, .crm = 7, .opc1 = 5, .opc2 = 2,
409       .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
410 };
411 
412 static void cortex_a9_initfn(Object *obj)
413 {
414     ARMCPU *cpu = ARM_CPU(obj);
415 
416     cpu->dtb_compatible = "arm,cortex-a9";
417     set_feature(&cpu->env, ARM_FEATURE_V7);
418     set_feature(&cpu->env, ARM_FEATURE_NEON);
419     set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
420     set_feature(&cpu->env, ARM_FEATURE_EL3);
421     /*
422      * Note that A9 supports the MP extensions even for
423      * A9UP and single-core A9MP (which are both different
424      * and valid configurations; we don't model A9UP).
425      */
426     set_feature(&cpu->env, ARM_FEATURE_V7MP);
427     set_feature(&cpu->env, ARM_FEATURE_CBAR);
428     cpu->midr = 0x410fc090;
429     cpu->reset_fpsid = 0x41033090;
430     cpu->isar.mvfr0 = 0x11110222;
431     cpu->isar.mvfr1 = 0x01111111;
432     cpu->ctr = 0x80038003;
433     cpu->reset_sctlr = 0x00c50078;
434     cpu->isar.id_pfr0 = 0x1031;
435     cpu->isar.id_pfr1 = 0x11;
436     cpu->isar.id_dfr0 = 0x000;
437     cpu->id_afr0 = 0;
438     cpu->isar.id_mmfr0 = 0x00100103;
439     cpu->isar.id_mmfr1 = 0x20000000;
440     cpu->isar.id_mmfr2 = 0x01230000;
441     cpu->isar.id_mmfr3 = 0x00002111;
442     cpu->isar.id_isar0 = 0x00101111;
443     cpu->isar.id_isar1 = 0x13112111;
444     cpu->isar.id_isar2 = 0x21232041;
445     cpu->isar.id_isar3 = 0x11112131;
446     cpu->isar.id_isar4 = 0x00111142;
447     cpu->isar.dbgdidr = 0x35141000;
448     cpu->clidr = (1 << 27) | (1 << 24) | 3;
449     cpu->ccsidr[0] = 0xe00fe019; /* 16k L1 dcache. */
450     cpu->ccsidr[1] = 0x200fe019; /* 16k L1 icache. */
451     cpu->isar.reset_pmcr_el0 = 0x41093000;
452     define_arm_cp_regs(cpu, cortexa9_cp_reginfo);
453 }
454 
455 #ifndef CONFIG_USER_ONLY
456 static uint64_t a15_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
457 {
458     MachineState *ms = MACHINE(qdev_get_machine());
459 
460     /*
461      * Linux wants the number of processors from here.
462      * Might as well set the interrupt-controller bit too.
463      */
464     return ((ms->smp.cpus - 1) << 24) | (1 << 23);
465 }
466 #endif
467 
468 static const ARMCPRegInfo cortexa15_cp_reginfo[] = {
469 #ifndef CONFIG_USER_ONLY
470     { .name = "L2CTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2,
471       .access = PL1_RW, .resetvalue = 0, .readfn = a15_l2ctlr_read,
472       .writefn = arm_cp_write_ignore, },
473 #endif
474     { .name = "L2ECTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 3,
475       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
476 };
477 
478 static void cortex_a7_initfn(Object *obj)
479 {
480     ARMCPU *cpu = ARM_CPU(obj);
481 
482     cpu->dtb_compatible = "arm,cortex-a7";
483     set_feature(&cpu->env, ARM_FEATURE_V7VE);
484     set_feature(&cpu->env, ARM_FEATURE_NEON);
485     set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
486     set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
487     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
488     set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
489     set_feature(&cpu->env, ARM_FEATURE_EL2);
490     set_feature(&cpu->env, ARM_FEATURE_EL3);
491     set_feature(&cpu->env, ARM_FEATURE_PMU);
492     cpu->midr = 0x410fc075;
493     cpu->reset_fpsid = 0x41023075;
494     cpu->isar.mvfr0 = 0x10110222;
495     cpu->isar.mvfr1 = 0x11111111;
496     cpu->ctr = 0x84448003;
497     cpu->reset_sctlr = 0x00c50078;
498     cpu->isar.id_pfr0 = 0x00001131;
499     cpu->isar.id_pfr1 = 0x00011011;
500     cpu->isar.id_dfr0 = 0x02010555;
501     cpu->id_afr0 = 0x00000000;
502     cpu->isar.id_mmfr0 = 0x10101105;
503     cpu->isar.id_mmfr1 = 0x40000000;
504     cpu->isar.id_mmfr2 = 0x01240000;
505     cpu->isar.id_mmfr3 = 0x02102211;
506     /*
507      * a7_mpcore_r0p5_trm, page 4-4 gives 0x01101110; but
508      * table 4-41 gives 0x02101110, which includes the arm div insns.
509      */
510     cpu->isar.id_isar0 = 0x02101110;
511     cpu->isar.id_isar1 = 0x13112111;
512     cpu->isar.id_isar2 = 0x21232041;
513     cpu->isar.id_isar3 = 0x11112131;
514     cpu->isar.id_isar4 = 0x10011142;
515     cpu->isar.dbgdidr = 0x3515f005;
516     cpu->isar.dbgdevid = 0x01110f13;
517     cpu->isar.dbgdevid1 = 0x1;
518     cpu->clidr = 0x0a200023;
519     cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */
520     cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */
521     cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
522     cpu->isar.reset_pmcr_el0 = 0x41072000;
523     define_arm_cp_regs(cpu, cortexa15_cp_reginfo); /* Same as A15 */
524 }
525 
526 static void cortex_a15_initfn(Object *obj)
527 {
528     ARMCPU *cpu = ARM_CPU(obj);
529 
530     cpu->dtb_compatible = "arm,cortex-a15";
531     set_feature(&cpu->env, ARM_FEATURE_V7VE);
532     set_feature(&cpu->env, ARM_FEATURE_NEON);
533     set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
534     set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
535     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
536     set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
537     set_feature(&cpu->env, ARM_FEATURE_EL2);
538     set_feature(&cpu->env, ARM_FEATURE_EL3);
539     set_feature(&cpu->env, ARM_FEATURE_PMU);
540     /* r4p0 cpu, not requiring expensive tlb flush errata */
541     cpu->midr = 0x414fc0f0;
542     cpu->revidr = 0x0;
543     cpu->reset_fpsid = 0x410430f0;
544     cpu->isar.mvfr0 = 0x10110222;
545     cpu->isar.mvfr1 = 0x11111111;
546     cpu->ctr = 0x8444c004;
547     cpu->reset_sctlr = 0x00c50078;
548     cpu->isar.id_pfr0 = 0x00001131;
549     cpu->isar.id_pfr1 = 0x00011011;
550     cpu->isar.id_dfr0 = 0x02010555;
551     cpu->id_afr0 = 0x00000000;
552     cpu->isar.id_mmfr0 = 0x10201105;
553     cpu->isar.id_mmfr1 = 0x20000000;
554     cpu->isar.id_mmfr2 = 0x01240000;
555     cpu->isar.id_mmfr3 = 0x02102211;
556     cpu->isar.id_isar0 = 0x02101110;
557     cpu->isar.id_isar1 = 0x13112111;
558     cpu->isar.id_isar2 = 0x21232041;
559     cpu->isar.id_isar3 = 0x11112131;
560     cpu->isar.id_isar4 = 0x10011142;
561     cpu->isar.dbgdidr = 0x3515f021;
562     cpu->isar.dbgdevid = 0x01110f13;
563     cpu->isar.dbgdevid1 = 0x0;
564     cpu->clidr = 0x0a200023;
565     cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */
566     cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */
567     cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
568     cpu->isar.reset_pmcr_el0 = 0x410F3000;
569     define_arm_cp_regs(cpu, cortexa15_cp_reginfo);
570 }
571 
572 static void cortex_m0_initfn(Object *obj)
573 {
574     ARMCPU *cpu = ARM_CPU(obj);
575     set_feature(&cpu->env, ARM_FEATURE_V6);
576     set_feature(&cpu->env, ARM_FEATURE_M);
577 
578     cpu->midr = 0x410cc200;
579 
580     /*
581      * These ID register values are not guest visible, because
582      * we do not implement the Main Extension. They must be set
583      * to values corresponding to the Cortex-M0's implemented
584      * features, because QEMU generally controls its emulation
585      * by looking at ID register fields. We use the same values as
586      * for the M3.
587      */
588     cpu->isar.id_pfr0 = 0x00000030;
589     cpu->isar.id_pfr1 = 0x00000200;
590     cpu->isar.id_dfr0 = 0x00100000;
591     cpu->id_afr0 = 0x00000000;
592     cpu->isar.id_mmfr0 = 0x00000030;
593     cpu->isar.id_mmfr1 = 0x00000000;
594     cpu->isar.id_mmfr2 = 0x00000000;
595     cpu->isar.id_mmfr3 = 0x00000000;
596     cpu->isar.id_isar0 = 0x01141110;
597     cpu->isar.id_isar1 = 0x02111000;
598     cpu->isar.id_isar2 = 0x21112231;
599     cpu->isar.id_isar3 = 0x01111110;
600     cpu->isar.id_isar4 = 0x01310102;
601     cpu->isar.id_isar5 = 0x00000000;
602     cpu->isar.id_isar6 = 0x00000000;
603 }
604 
605 static void cortex_m3_initfn(Object *obj)
606 {
607     ARMCPU *cpu = ARM_CPU(obj);
608     set_feature(&cpu->env, ARM_FEATURE_V7);
609     set_feature(&cpu->env, ARM_FEATURE_M);
610     set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
611     cpu->midr = 0x410fc231;
612     cpu->pmsav7_dregion = 8;
613     cpu->isar.id_pfr0 = 0x00000030;
614     cpu->isar.id_pfr1 = 0x00000200;
615     cpu->isar.id_dfr0 = 0x00100000;
616     cpu->id_afr0 = 0x00000000;
617     cpu->isar.id_mmfr0 = 0x00000030;
618     cpu->isar.id_mmfr1 = 0x00000000;
619     cpu->isar.id_mmfr2 = 0x00000000;
620     cpu->isar.id_mmfr3 = 0x00000000;
621     cpu->isar.id_isar0 = 0x01141110;
622     cpu->isar.id_isar1 = 0x02111000;
623     cpu->isar.id_isar2 = 0x21112231;
624     cpu->isar.id_isar3 = 0x01111110;
625     cpu->isar.id_isar4 = 0x01310102;
626     cpu->isar.id_isar5 = 0x00000000;
627     cpu->isar.id_isar6 = 0x00000000;
628 }
629 
630 static void cortex_m4_initfn(Object *obj)
631 {
632     ARMCPU *cpu = ARM_CPU(obj);
633 
634     set_feature(&cpu->env, ARM_FEATURE_V7);
635     set_feature(&cpu->env, ARM_FEATURE_M);
636     set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
637     set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
638     cpu->midr = 0x410fc240; /* r0p0 */
639     cpu->pmsav7_dregion = 8;
640     cpu->isar.mvfr0 = 0x10110021;
641     cpu->isar.mvfr1 = 0x11000011;
642     cpu->isar.mvfr2 = 0x00000000;
643     cpu->isar.id_pfr0 = 0x00000030;
644     cpu->isar.id_pfr1 = 0x00000200;
645     cpu->isar.id_dfr0 = 0x00100000;
646     cpu->id_afr0 = 0x00000000;
647     cpu->isar.id_mmfr0 = 0x00000030;
648     cpu->isar.id_mmfr1 = 0x00000000;
649     cpu->isar.id_mmfr2 = 0x00000000;
650     cpu->isar.id_mmfr3 = 0x00000000;
651     cpu->isar.id_isar0 = 0x01141110;
652     cpu->isar.id_isar1 = 0x02111000;
653     cpu->isar.id_isar2 = 0x21112231;
654     cpu->isar.id_isar3 = 0x01111110;
655     cpu->isar.id_isar4 = 0x01310102;
656     cpu->isar.id_isar5 = 0x00000000;
657     cpu->isar.id_isar6 = 0x00000000;
658 }
659 
660 static void cortex_m7_initfn(Object *obj)
661 {
662     ARMCPU *cpu = ARM_CPU(obj);
663 
664     set_feature(&cpu->env, ARM_FEATURE_V7);
665     set_feature(&cpu->env, ARM_FEATURE_M);
666     set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
667     set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
668     cpu->midr = 0x411fc272; /* r1p2 */
669     cpu->pmsav7_dregion = 8;
670     cpu->isar.mvfr0 = 0x10110221;
671     cpu->isar.mvfr1 = 0x12000011;
672     cpu->isar.mvfr2 = 0x00000040;
673     cpu->isar.id_pfr0 = 0x00000030;
674     cpu->isar.id_pfr1 = 0x00000200;
675     cpu->isar.id_dfr0 = 0x00100000;
676     cpu->id_afr0 = 0x00000000;
677     cpu->isar.id_mmfr0 = 0x00100030;
678     cpu->isar.id_mmfr1 = 0x00000000;
679     cpu->isar.id_mmfr2 = 0x01000000;
680     cpu->isar.id_mmfr3 = 0x00000000;
681     cpu->isar.id_isar0 = 0x01101110;
682     cpu->isar.id_isar1 = 0x02112000;
683     cpu->isar.id_isar2 = 0x20232231;
684     cpu->isar.id_isar3 = 0x01111131;
685     cpu->isar.id_isar4 = 0x01310132;
686     cpu->isar.id_isar5 = 0x00000000;
687     cpu->isar.id_isar6 = 0x00000000;
688 }
689 
690 static void cortex_m33_initfn(Object *obj)
691 {
692     ARMCPU *cpu = ARM_CPU(obj);
693 
694     set_feature(&cpu->env, ARM_FEATURE_V8);
695     set_feature(&cpu->env, ARM_FEATURE_M);
696     set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
697     set_feature(&cpu->env, ARM_FEATURE_M_SECURITY);
698     set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
699     cpu->midr = 0x410fd213; /* r0p3 */
700     cpu->pmsav7_dregion = 16;
701     cpu->sau_sregion = 8;
702     cpu->isar.mvfr0 = 0x10110021;
703     cpu->isar.mvfr1 = 0x11000011;
704     cpu->isar.mvfr2 = 0x00000040;
705     cpu->isar.id_pfr0 = 0x00000030;
706     cpu->isar.id_pfr1 = 0x00000210;
707     cpu->isar.id_dfr0 = 0x00200000;
708     cpu->id_afr0 = 0x00000000;
709     cpu->isar.id_mmfr0 = 0x00101F40;
710     cpu->isar.id_mmfr1 = 0x00000000;
711     cpu->isar.id_mmfr2 = 0x01000000;
712     cpu->isar.id_mmfr3 = 0x00000000;
713     cpu->isar.id_isar0 = 0x01101110;
714     cpu->isar.id_isar1 = 0x02212000;
715     cpu->isar.id_isar2 = 0x20232232;
716     cpu->isar.id_isar3 = 0x01111131;
717     cpu->isar.id_isar4 = 0x01310132;
718     cpu->isar.id_isar5 = 0x00000000;
719     cpu->isar.id_isar6 = 0x00000000;
720     cpu->clidr = 0x00000000;
721     cpu->ctr = 0x8000c000;
722 }
723 
724 static void cortex_m55_initfn(Object *obj)
725 {
726     ARMCPU *cpu = ARM_CPU(obj);
727 
728     set_feature(&cpu->env, ARM_FEATURE_V8);
729     set_feature(&cpu->env, ARM_FEATURE_V8_1M);
730     set_feature(&cpu->env, ARM_FEATURE_M);
731     set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
732     set_feature(&cpu->env, ARM_FEATURE_M_SECURITY);
733     set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
734     cpu->midr = 0x410fd221; /* r0p1 */
735     cpu->revidr = 0;
736     cpu->pmsav7_dregion = 16;
737     cpu->sau_sregion = 8;
738     /* These are the MVFR* values for the FPU + full MVE configuration */
739     cpu->isar.mvfr0 = 0x10110221;
740     cpu->isar.mvfr1 = 0x12100211;
741     cpu->isar.mvfr2 = 0x00000040;
742     cpu->isar.id_pfr0 = 0x20000030;
743     cpu->isar.id_pfr1 = 0x00000230;
744     cpu->isar.id_dfr0 = 0x10200000;
745     cpu->id_afr0 = 0x00000000;
746     cpu->isar.id_mmfr0 = 0x00111040;
747     cpu->isar.id_mmfr1 = 0x00000000;
748     cpu->isar.id_mmfr2 = 0x01000000;
749     cpu->isar.id_mmfr3 = 0x00000011;
750     cpu->isar.id_isar0 = 0x01103110;
751     cpu->isar.id_isar1 = 0x02212000;
752     cpu->isar.id_isar2 = 0x20232232;
753     cpu->isar.id_isar3 = 0x01111131;
754     cpu->isar.id_isar4 = 0x01310132;
755     cpu->isar.id_isar5 = 0x00000000;
756     cpu->isar.id_isar6 = 0x00000000;
757     cpu->clidr = 0x00000000; /* caches not implemented */
758     cpu->ctr = 0x8303c003;
759 }
760 
761 static const ARMCPRegInfo cortexr5_cp_reginfo[] = {
762     /* Dummy the TCM region regs for the moment */
763     { .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0,
764       .access = PL1_RW, .type = ARM_CP_CONST },
765     { .name = "BTCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 1,
766       .access = PL1_RW, .type = ARM_CP_CONST },
767     { .name = "DCACHE_INVAL", .cp = 15, .opc1 = 0, .crn = 15, .crm = 5,
768       .opc2 = 0, .access = PL1_W, .type = ARM_CP_NOP },
769 };
770 
771 static void cortex_r5_initfn(Object *obj)
772 {
773     ARMCPU *cpu = ARM_CPU(obj);
774 
775     set_feature(&cpu->env, ARM_FEATURE_V7);
776     set_feature(&cpu->env, ARM_FEATURE_V7MP);
777     set_feature(&cpu->env, ARM_FEATURE_PMSA);
778     set_feature(&cpu->env, ARM_FEATURE_PMU);
779     cpu->midr = 0x411fc153; /* r1p3 */
780     cpu->isar.id_pfr0 = 0x0131;
781     cpu->isar.id_pfr1 = 0x001;
782     cpu->isar.id_dfr0 = 0x010400;
783     cpu->id_afr0 = 0x0;
784     cpu->isar.id_mmfr0 = 0x0210030;
785     cpu->isar.id_mmfr1 = 0x00000000;
786     cpu->isar.id_mmfr2 = 0x01200000;
787     cpu->isar.id_mmfr3 = 0x0211;
788     cpu->isar.id_isar0 = 0x02101111;
789     cpu->isar.id_isar1 = 0x13112111;
790     cpu->isar.id_isar2 = 0x21232141;
791     cpu->isar.id_isar3 = 0x01112131;
792     cpu->isar.id_isar4 = 0x0010142;
793     cpu->isar.id_isar5 = 0x0;
794     cpu->isar.id_isar6 = 0x0;
795     cpu->mp_is_up = true;
796     cpu->pmsav7_dregion = 16;
797     cpu->isar.reset_pmcr_el0 = 0x41151800;
798     define_arm_cp_regs(cpu, cortexr5_cp_reginfo);
799 }
800 
801 static void cortex_r52_initfn(Object *obj)
802 {
803     ARMCPU *cpu = ARM_CPU(obj);
804 
805     set_feature(&cpu->env, ARM_FEATURE_V8);
806     set_feature(&cpu->env, ARM_FEATURE_EL2);
807     set_feature(&cpu->env, ARM_FEATURE_PMSA);
808     set_feature(&cpu->env, ARM_FEATURE_NEON);
809     set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
810     cpu->midr = 0x411fd133; /* r1p3 */
811     cpu->revidr = 0x00000000;
812     cpu->reset_fpsid = 0x41034023;
813     cpu->isar.mvfr0 = 0x10110222;
814     cpu->isar.mvfr1 = 0x12111111;
815     cpu->isar.mvfr2 = 0x00000043;
816     cpu->ctr = 0x8144c004;
817     cpu->reset_sctlr = 0x30c50838;
818     cpu->isar.id_pfr0 = 0x00000131;
819     cpu->isar.id_pfr1 = 0x10111001;
820     cpu->isar.id_dfr0 = 0x03010006;
821     cpu->id_afr0 = 0x00000000;
822     cpu->isar.id_mmfr0 = 0x00211040;
823     cpu->isar.id_mmfr1 = 0x40000000;
824     cpu->isar.id_mmfr2 = 0x01200000;
825     cpu->isar.id_mmfr3 = 0xf0102211;
826     cpu->isar.id_mmfr4 = 0x00000010;
827     cpu->isar.id_isar0 = 0x02101110;
828     cpu->isar.id_isar1 = 0x13112111;
829     cpu->isar.id_isar2 = 0x21232142;
830     cpu->isar.id_isar3 = 0x01112131;
831     cpu->isar.id_isar4 = 0x00010142;
832     cpu->isar.id_isar5 = 0x00010001;
833     cpu->isar.dbgdidr = 0x77168000;
834     cpu->clidr = (1 << 27) | (1 << 24) | 0x3;
835     cpu->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */
836     cpu->ccsidr[1] = 0x201fe00a; /* 32KB L1 icache */
837 
838     cpu->pmsav7_dregion = 16;
839     cpu->pmsav8r_hdregion = 16;
840 }
841 
842 static void cortex_r5f_initfn(Object *obj)
843 {
844     ARMCPU *cpu = ARM_CPU(obj);
845 
846     cortex_r5_initfn(obj);
847     cpu->isar.mvfr0 = 0x10110221;
848     cpu->isar.mvfr1 = 0x00000011;
849 }
850 
851 static void ti925t_initfn(Object *obj)
852 {
853     ARMCPU *cpu = ARM_CPU(obj);
854     set_feature(&cpu->env, ARM_FEATURE_V4T);
855     set_feature(&cpu->env, ARM_FEATURE_OMAPCP);
856     cpu->midr = ARM_CPUID_TI925T;
857     cpu->ctr = 0x5109149;
858     cpu->reset_sctlr = 0x00000070;
859 }
860 
861 static void sa1100_initfn(Object *obj)
862 {
863     ARMCPU *cpu = ARM_CPU(obj);
864 
865     cpu->dtb_compatible = "intel,sa1100";
866     set_feature(&cpu->env, ARM_FEATURE_STRONGARM);
867     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
868     cpu->midr = 0x4401A11B;
869     cpu->reset_sctlr = 0x00000070;
870 }
871 
872 static void sa1110_initfn(Object *obj)
873 {
874     ARMCPU *cpu = ARM_CPU(obj);
875     set_feature(&cpu->env, ARM_FEATURE_STRONGARM);
876     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
877     cpu->midr = 0x6901B119;
878     cpu->reset_sctlr = 0x00000070;
879 }
880 
881 static void pxa250_initfn(Object *obj)
882 {
883     ARMCPU *cpu = ARM_CPU(obj);
884 
885     cpu->dtb_compatible = "marvell,xscale";
886     set_feature(&cpu->env, ARM_FEATURE_V5);
887     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
888     cpu->midr = 0x69052100;
889     cpu->ctr = 0xd172172;
890     cpu->reset_sctlr = 0x00000078;
891 }
892 
893 static void pxa255_initfn(Object *obj)
894 {
895     ARMCPU *cpu = ARM_CPU(obj);
896 
897     cpu->dtb_compatible = "marvell,xscale";
898     set_feature(&cpu->env, ARM_FEATURE_V5);
899     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
900     cpu->midr = 0x69052d00;
901     cpu->ctr = 0xd172172;
902     cpu->reset_sctlr = 0x00000078;
903 }
904 
905 static void pxa260_initfn(Object *obj)
906 {
907     ARMCPU *cpu = ARM_CPU(obj);
908 
909     cpu->dtb_compatible = "marvell,xscale";
910     set_feature(&cpu->env, ARM_FEATURE_V5);
911     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
912     cpu->midr = 0x69052903;
913     cpu->ctr = 0xd172172;
914     cpu->reset_sctlr = 0x00000078;
915 }
916 
917 static void pxa261_initfn(Object *obj)
918 {
919     ARMCPU *cpu = ARM_CPU(obj);
920 
921     cpu->dtb_compatible = "marvell,xscale";
922     set_feature(&cpu->env, ARM_FEATURE_V5);
923     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
924     cpu->midr = 0x69052d05;
925     cpu->ctr = 0xd172172;
926     cpu->reset_sctlr = 0x00000078;
927 }
928 
929 static void pxa262_initfn(Object *obj)
930 {
931     ARMCPU *cpu = ARM_CPU(obj);
932 
933     cpu->dtb_compatible = "marvell,xscale";
934     set_feature(&cpu->env, ARM_FEATURE_V5);
935     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
936     cpu->midr = 0x69052d06;
937     cpu->ctr = 0xd172172;
938     cpu->reset_sctlr = 0x00000078;
939 }
940 
941 static void pxa270a0_initfn(Object *obj)
942 {
943     ARMCPU *cpu = ARM_CPU(obj);
944 
945     cpu->dtb_compatible = "marvell,xscale";
946     set_feature(&cpu->env, ARM_FEATURE_V5);
947     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
948     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
949     cpu->midr = 0x69054110;
950     cpu->ctr = 0xd172172;
951     cpu->reset_sctlr = 0x00000078;
952 }
953 
954 static void pxa270a1_initfn(Object *obj)
955 {
956     ARMCPU *cpu = ARM_CPU(obj);
957 
958     cpu->dtb_compatible = "marvell,xscale";
959     set_feature(&cpu->env, ARM_FEATURE_V5);
960     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
961     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
962     cpu->midr = 0x69054111;
963     cpu->ctr = 0xd172172;
964     cpu->reset_sctlr = 0x00000078;
965 }
966 
967 static void pxa270b0_initfn(Object *obj)
968 {
969     ARMCPU *cpu = ARM_CPU(obj);
970 
971     cpu->dtb_compatible = "marvell,xscale";
972     set_feature(&cpu->env, ARM_FEATURE_V5);
973     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
974     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
975     cpu->midr = 0x69054112;
976     cpu->ctr = 0xd172172;
977     cpu->reset_sctlr = 0x00000078;
978 }
979 
980 static void pxa270b1_initfn(Object *obj)
981 {
982     ARMCPU *cpu = ARM_CPU(obj);
983 
984     cpu->dtb_compatible = "marvell,xscale";
985     set_feature(&cpu->env, ARM_FEATURE_V5);
986     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
987     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
988     cpu->midr = 0x69054113;
989     cpu->ctr = 0xd172172;
990     cpu->reset_sctlr = 0x00000078;
991 }
992 
993 static void pxa270c0_initfn(Object *obj)
994 {
995     ARMCPU *cpu = ARM_CPU(obj);
996 
997     cpu->dtb_compatible = "marvell,xscale";
998     set_feature(&cpu->env, ARM_FEATURE_V5);
999     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1000     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
1001     cpu->midr = 0x69054114;
1002     cpu->ctr = 0xd172172;
1003     cpu->reset_sctlr = 0x00000078;
1004 }
1005 
1006 static void pxa270c5_initfn(Object *obj)
1007 {
1008     ARMCPU *cpu = ARM_CPU(obj);
1009 
1010     cpu->dtb_compatible = "marvell,xscale";
1011     set_feature(&cpu->env, ARM_FEATURE_V5);
1012     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
1013     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
1014     cpu->midr = 0x69054117;
1015     cpu->ctr = 0xd172172;
1016     cpu->reset_sctlr = 0x00000078;
1017 }
1018 
1019 static const struct TCGCPUOps arm_v7m_tcg_ops = {
1020     .initialize = arm_translate_init,
1021     .synchronize_from_tb = arm_cpu_synchronize_from_tb,
1022     .debug_excp_handler = arm_debug_excp_handler,
1023     .restore_state_to_opc = arm_restore_state_to_opc,
1024 
1025 #ifdef CONFIG_USER_ONLY
1026     .record_sigsegv = arm_cpu_record_sigsegv,
1027     .record_sigbus = arm_cpu_record_sigbus,
1028 #else
1029     .tlb_fill = arm_cpu_tlb_fill,
1030     .cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt,
1031     .do_interrupt = arm_v7m_cpu_do_interrupt,
1032     .do_transaction_failed = arm_cpu_do_transaction_failed,
1033     .do_unaligned_access = arm_cpu_do_unaligned_access,
1034     .adjust_watchpoint_address = arm_adjust_watchpoint_address,
1035     .debug_check_watchpoint = arm_debug_check_watchpoint,
1036     .debug_check_breakpoint = arm_debug_check_breakpoint,
1037 #endif /* !CONFIG_USER_ONLY */
1038 };
1039 
1040 static void arm_v7m_class_init(ObjectClass *oc, void *data)
1041 {
1042     ARMCPUClass *acc = ARM_CPU_CLASS(oc);
1043     CPUClass *cc = CPU_CLASS(oc);
1044 
1045     acc->info = data;
1046     cc->tcg_ops = &arm_v7m_tcg_ops;
1047     cc->gdb_core_xml_file = "arm-m-profile.xml";
1048 }
1049 
1050 #ifndef TARGET_AARCH64
1051 /*
1052  * -cpu max: a CPU with as many features enabled as our emulation supports.
1053  * The version of '-cpu max' for qemu-system-aarch64 is defined in cpu64.c;
1054  * this only needs to handle 32 bits, and need not care about KVM.
1055  */
1056 static void arm_max_initfn(Object *obj)
1057 {
1058     ARMCPU *cpu = ARM_CPU(obj);
1059 
1060     /* aarch64_a57_initfn, advertising none of the aarch64 features */
1061     cpu->dtb_compatible = "arm,cortex-a57";
1062     set_feature(&cpu->env, ARM_FEATURE_V8);
1063     set_feature(&cpu->env, ARM_FEATURE_NEON);
1064     set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
1065     set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
1066     set_feature(&cpu->env, ARM_FEATURE_EL2);
1067     set_feature(&cpu->env, ARM_FEATURE_EL3);
1068     set_feature(&cpu->env, ARM_FEATURE_PMU);
1069     cpu->midr = 0x411fd070;
1070     cpu->revidr = 0x00000000;
1071     cpu->reset_fpsid = 0x41034070;
1072     cpu->isar.mvfr0 = 0x10110222;
1073     cpu->isar.mvfr1 = 0x12111111;
1074     cpu->isar.mvfr2 = 0x00000043;
1075     cpu->ctr = 0x8444c004;
1076     cpu->reset_sctlr = 0x00c50838;
1077     cpu->isar.id_pfr0 = 0x00000131;
1078     cpu->isar.id_pfr1 = 0x00011011;
1079     cpu->isar.id_dfr0 = 0x03010066;
1080     cpu->id_afr0 = 0x00000000;
1081     cpu->isar.id_mmfr0 = 0x10101105;
1082     cpu->isar.id_mmfr1 = 0x40000000;
1083     cpu->isar.id_mmfr2 = 0x01260000;
1084     cpu->isar.id_mmfr3 = 0x02102211;
1085     cpu->isar.id_isar0 = 0x02101110;
1086     cpu->isar.id_isar1 = 0x13112111;
1087     cpu->isar.id_isar2 = 0x21232042;
1088     cpu->isar.id_isar3 = 0x01112131;
1089     cpu->isar.id_isar4 = 0x00011142;
1090     cpu->isar.id_isar5 = 0x00011121;
1091     cpu->isar.id_isar6 = 0;
1092     cpu->isar.dbgdidr = 0x3516d000;
1093     cpu->isar.dbgdevid = 0x00110f13;
1094     cpu->isar.dbgdevid1 = 0x2;
1095     cpu->isar.reset_pmcr_el0 = 0x41013000;
1096     cpu->clidr = 0x0a200023;
1097     cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */
1098     cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */
1099     cpu->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */
1100     define_cortex_a72_a57_a53_cp_reginfo(cpu);
1101 
1102     aa32_max_features(cpu);
1103 
1104 #ifdef CONFIG_USER_ONLY
1105     /*
1106      * Break with true ARMv8 and add back old-style VFP short-vector support.
1107      * Only do this for user-mode, where -cpu max is the default, so that
1108      * older v6 and v7 programs are more likely to work without adjustment.
1109      */
1110     cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
1111 #endif
1112 }
1113 #endif /* !TARGET_AARCH64 */
1114 
1115 static const ARMCPUInfo arm_tcg_cpus[] = {
1116     { .name = "arm926",      .initfn = arm926_initfn },
1117     { .name = "arm946",      .initfn = arm946_initfn },
1118     { .name = "arm1026",     .initfn = arm1026_initfn },
1119     /*
1120      * What QEMU calls "arm1136-r2" is actually the 1136 r0p2, i.e. an
1121      * older core than plain "arm1136". In particular this does not
1122      * have the v6K features.
1123      */
1124     { .name = "arm1136-r2",  .initfn = arm1136_r2_initfn },
1125     { .name = "arm1136",     .initfn = arm1136_initfn },
1126     { .name = "arm1176",     .initfn = arm1176_initfn },
1127     { .name = "arm11mpcore", .initfn = arm11mpcore_initfn },
1128     { .name = "cortex-a7",   .initfn = cortex_a7_initfn },
1129     { .name = "cortex-a8",   .initfn = cortex_a8_initfn },
1130     { .name = "cortex-a9",   .initfn = cortex_a9_initfn },
1131     { .name = "cortex-a15",  .initfn = cortex_a15_initfn },
1132     { .name = "cortex-m0",   .initfn = cortex_m0_initfn,
1133                              .class_init = arm_v7m_class_init },
1134     { .name = "cortex-m3",   .initfn = cortex_m3_initfn,
1135                              .class_init = arm_v7m_class_init },
1136     { .name = "cortex-m4",   .initfn = cortex_m4_initfn,
1137                              .class_init = arm_v7m_class_init },
1138     { .name = "cortex-m7",   .initfn = cortex_m7_initfn,
1139                              .class_init = arm_v7m_class_init },
1140     { .name = "cortex-m33",  .initfn = cortex_m33_initfn,
1141                              .class_init = arm_v7m_class_init },
1142     { .name = "cortex-m55",  .initfn = cortex_m55_initfn,
1143                              .class_init = arm_v7m_class_init },
1144     { .name = "cortex-r5",   .initfn = cortex_r5_initfn },
1145     { .name = "cortex-r5f",  .initfn = cortex_r5f_initfn },
1146     { .name = "cortex-r52",  .initfn = cortex_r52_initfn },
1147     { .name = "ti925t",      .initfn = ti925t_initfn },
1148     { .name = "sa1100",      .initfn = sa1100_initfn },
1149     { .name = "sa1110",      .initfn = sa1110_initfn },
1150     { .name = "pxa250",      .initfn = pxa250_initfn },
1151     { .name = "pxa255",      .initfn = pxa255_initfn },
1152     { .name = "pxa260",      .initfn = pxa260_initfn },
1153     { .name = "pxa261",      .initfn = pxa261_initfn },
1154     { .name = "pxa262",      .initfn = pxa262_initfn },
1155     /* "pxa270" is an alias for "pxa270-a0" */
1156     { .name = "pxa270",      .initfn = pxa270a0_initfn },
1157     { .name = "pxa270-a0",   .initfn = pxa270a0_initfn },
1158     { .name = "pxa270-a1",   .initfn = pxa270a1_initfn },
1159     { .name = "pxa270-b0",   .initfn = pxa270b0_initfn },
1160     { .name = "pxa270-b1",   .initfn = pxa270b1_initfn },
1161     { .name = "pxa270-c0",   .initfn = pxa270c0_initfn },
1162     { .name = "pxa270-c5",   .initfn = pxa270c5_initfn },
1163 #ifndef TARGET_AARCH64
1164     { .name = "max",         .initfn = arm_max_initfn },
1165 #endif
1166 #ifdef CONFIG_USER_ONLY
1167     { .name = "any",         .initfn = arm_max_initfn },
1168 #endif
1169 };
1170 
1171 static const TypeInfo idau_interface_type_info = {
1172     .name = TYPE_IDAU_INTERFACE,
1173     .parent = TYPE_INTERFACE,
1174     .class_size = sizeof(IDAUInterfaceClass),
1175 };
1176 
1177 static void arm_tcg_cpu_register_types(void)
1178 {
1179     size_t i;
1180 
1181     type_register_static(&idau_interface_type_info);
1182     for (i = 0; i < ARRAY_SIZE(arm_tcg_cpus); ++i) {
1183         arm_cpu_register(&arm_tcg_cpus[i]);
1184     }
1185 }
1186 
1187 type_init(arm_tcg_cpu_register_types)
1188 
1189 #endif /* !CONFIG_USER_ONLY || !TARGET_AARCH64 */
1190