xref: /openbmc/qemu/target/arm/tcg/cpu32.c (revision bbf6c6db)
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 
21 
22 /* Share AArch32 -cpu max features with AArch64. */
23 void aa32_max_features(ARMCPU *cpu)
24 {
25     uint32_t t;
26 
27     /* Add additional features supported by QEMU */
28     t = cpu->isar.id_isar5;
29     t = FIELD_DP32(t, ID_ISAR5, AES, 2);          /* FEAT_PMULL */
30     t = FIELD_DP32(t, ID_ISAR5, SHA1, 1);         /* FEAT_SHA1 */
31     t = FIELD_DP32(t, ID_ISAR5, SHA2, 1);         /* FEAT_SHA256 */
32     t = FIELD_DP32(t, ID_ISAR5, CRC32, 1);
33     t = FIELD_DP32(t, ID_ISAR5, RDM, 1);          /* FEAT_RDM */
34     t = FIELD_DP32(t, ID_ISAR5, VCMA, 1);         /* FEAT_FCMA */
35     cpu->isar.id_isar5 = t;
36 
37     t = cpu->isar.id_isar6;
38     t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1);        /* FEAT_JSCVT */
39     t = FIELD_DP32(t, ID_ISAR6, DP, 1);           /* Feat_DotProd */
40     t = FIELD_DP32(t, ID_ISAR6, FHM, 1);          /* FEAT_FHM */
41     t = FIELD_DP32(t, ID_ISAR6, SB, 1);           /* FEAT_SB */
42     t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1);      /* FEAT_SPECRES */
43     t = FIELD_DP32(t, ID_ISAR6, BF16, 1);         /* FEAT_AA32BF16 */
44     t = FIELD_DP32(t, ID_ISAR6, I8MM, 1);         /* FEAT_AA32I8MM */
45     cpu->isar.id_isar6 = t;
46 
47     t = cpu->isar.mvfr1;
48     t = FIELD_DP32(t, MVFR1, FPHP, 3);            /* FEAT_FP16 */
49     t = FIELD_DP32(t, MVFR1, SIMDHP, 2);          /* FEAT_FP16 */
50     cpu->isar.mvfr1 = t;
51 
52     t = cpu->isar.mvfr2;
53     t = FIELD_DP32(t, MVFR2, SIMDMISC, 3);        /* SIMD MaxNum */
54     t = FIELD_DP32(t, MVFR2, FPMISC, 4);          /* FP MaxNum */
55     cpu->isar.mvfr2 = t;
56 
57     t = cpu->isar.id_mmfr3;
58     t = FIELD_DP32(t, ID_MMFR3, PAN, 2);          /* FEAT_PAN2 */
59     cpu->isar.id_mmfr3 = t;
60 
61     t = cpu->isar.id_mmfr4;
62     t = FIELD_DP32(t, ID_MMFR4, HPDS, 2);         /* FEAT_HPDS2 */
63     t = FIELD_DP32(t, ID_MMFR4, AC2, 1);          /* ACTLR2, HACTLR2 */
64     t = FIELD_DP32(t, ID_MMFR4, CNP, 1);          /* FEAT_TTCNP */
65     t = FIELD_DP32(t, ID_MMFR4, XNX, 1);          /* FEAT_XNX */
66     t = FIELD_DP32(t, ID_MMFR4, EVT, 2);          /* FEAT_EVT */
67     cpu->isar.id_mmfr4 = t;
68 
69     t = cpu->isar.id_mmfr5;
70     t = FIELD_DP32(t, ID_MMFR5, ETS, 1);          /* FEAT_ETS */
71     cpu->isar.id_mmfr5 = t;
72 
73     t = cpu->isar.id_pfr0;
74     t = FIELD_DP32(t, ID_PFR0, CSV2, 2);          /* FEAT_CVS2 */
75     t = FIELD_DP32(t, ID_PFR0, DIT, 1);           /* FEAT_DIT */
76     t = FIELD_DP32(t, ID_PFR0, RAS, 1);           /* FEAT_RAS */
77     cpu->isar.id_pfr0 = t;
78 
79     t = cpu->isar.id_pfr2;
80     t = FIELD_DP32(t, ID_PFR2, CSV3, 1);          /* FEAT_CSV3 */
81     t = FIELD_DP32(t, ID_PFR2, SSBS, 1);          /* FEAT_SSBS */
82     cpu->isar.id_pfr2 = t;
83 
84     t = cpu->isar.id_dfr0;
85     t = FIELD_DP32(t, ID_DFR0, COPDBG, 9);        /* FEAT_Debugv8p4 */
86     t = FIELD_DP32(t, ID_DFR0, COPSDBG, 9);       /* FEAT_Debugv8p4 */
87     t = FIELD_DP32(t, ID_DFR0, PERFMON, 6);       /* FEAT_PMUv3p5 */
88     cpu->isar.id_dfr0 = t;
89 
90     t = cpu->isar.id_dfr1;
91     t = FIELD_DP32(t, ID_DFR1, HPMN0, 1);         /* FEAT_HPMN0 */
92     cpu->isar.id_dfr1 = t;
93 }
94 
95 /* CPU models. These are not needed for the AArch64 linux-user build. */
96 #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
97 
98 static void arm926_initfn(Object *obj)
99 {
100     ARMCPU *cpu = ARM_CPU(obj);
101 
102     cpu->dtb_compatible = "arm,arm926";
103     set_feature(&cpu->env, ARM_FEATURE_V5);
104     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
105     set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN);
106     cpu->midr = 0x41069265;
107     cpu->reset_fpsid = 0x41011090;
108     cpu->ctr = 0x1dd20d2;
109     cpu->reset_sctlr = 0x00090078;
110 
111     /*
112      * ARMv5 does not have the ID_ISAR registers, but we can still
113      * set the field to indicate Jazelle support within QEMU.
114      */
115     cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1);
116     /*
117      * Similarly, we need to set MVFR0 fields to enable vfp and short vector
118      * support even though ARMv5 doesn't have this register.
119      */
120     cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
121     cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1);
122     cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1);
123 }
124 
125 static void arm946_initfn(Object *obj)
126 {
127     ARMCPU *cpu = ARM_CPU(obj);
128 
129     cpu->dtb_compatible = "arm,arm946";
130     set_feature(&cpu->env, ARM_FEATURE_V5);
131     set_feature(&cpu->env, ARM_FEATURE_PMSA);
132     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
133     cpu->midr = 0x41059461;
134     cpu->ctr = 0x0f004006;
135     cpu->reset_sctlr = 0x00000078;
136 }
137 
138 static void arm1026_initfn(Object *obj)
139 {
140     ARMCPU *cpu = ARM_CPU(obj);
141 
142     cpu->dtb_compatible = "arm,arm1026";
143     set_feature(&cpu->env, ARM_FEATURE_V5);
144     set_feature(&cpu->env, ARM_FEATURE_AUXCR);
145     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
146     set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN);
147     cpu->midr = 0x4106a262;
148     cpu->reset_fpsid = 0x410110a0;
149     cpu->ctr = 0x1dd20d2;
150     cpu->reset_sctlr = 0x00090078;
151     cpu->reset_auxcr = 1;
152 
153     /*
154      * ARMv5 does not have the ID_ISAR registers, but we can still
155      * set the field to indicate Jazelle support within QEMU.
156      */
157     cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1);
158     /*
159      * Similarly, we need to set MVFR0 fields to enable vfp and short vector
160      * support even though ARMv5 doesn't have this register.
161      */
162     cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
163     cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1);
164     cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1);
165 
166     {
167         /* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */
168         ARMCPRegInfo ifar = {
169             .name = "IFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 1,
170             .access = PL1_RW,
171             .fieldoffset = offsetof(CPUARMState, cp15.ifar_ns),
172             .resetvalue = 0
173         };
174         define_one_arm_cp_reg(cpu, &ifar);
175     }
176 }
177 
178 static void arm1136_r2_initfn(Object *obj)
179 {
180     ARMCPU *cpu = ARM_CPU(obj);
181     /*
182      * What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an
183      * older core than plain "arm1136". In particular this does not
184      * have the v6K features.
185      * These ID register values are correct for 1136 but may be wrong
186      * for 1136_r2 (in particular r0p2 does not actually implement most
187      * of the ID registers).
188      */
189 
190     cpu->dtb_compatible = "arm,arm1136";
191     set_feature(&cpu->env, ARM_FEATURE_V6);
192     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
193     set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG);
194     set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS);
195     cpu->midr = 0x4107b362;
196     cpu->reset_fpsid = 0x410120b4;
197     cpu->isar.mvfr0 = 0x11111111;
198     cpu->isar.mvfr1 = 0x00000000;
199     cpu->ctr = 0x1dd20d2;
200     cpu->reset_sctlr = 0x00050078;
201     cpu->isar.id_pfr0 = 0x111;
202     cpu->isar.id_pfr1 = 0x1;
203     cpu->isar.id_dfr0 = 0x2;
204     cpu->id_afr0 = 0x3;
205     cpu->isar.id_mmfr0 = 0x01130003;
206     cpu->isar.id_mmfr1 = 0x10030302;
207     cpu->isar.id_mmfr2 = 0x01222110;
208     cpu->isar.id_isar0 = 0x00140011;
209     cpu->isar.id_isar1 = 0x12002111;
210     cpu->isar.id_isar2 = 0x11231111;
211     cpu->isar.id_isar3 = 0x01102131;
212     cpu->isar.id_isar4 = 0x141;
213     cpu->reset_auxcr = 7;
214 }
215 
216 static void arm1136_initfn(Object *obj)
217 {
218     ARMCPU *cpu = ARM_CPU(obj);
219 
220     cpu->dtb_compatible = "arm,arm1136";
221     set_feature(&cpu->env, ARM_FEATURE_V6K);
222     set_feature(&cpu->env, ARM_FEATURE_V6);
223     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
224     set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG);
225     set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS);
226     cpu->midr = 0x4117b363;
227     cpu->reset_fpsid = 0x410120b4;
228     cpu->isar.mvfr0 = 0x11111111;
229     cpu->isar.mvfr1 = 0x00000000;
230     cpu->ctr = 0x1dd20d2;
231     cpu->reset_sctlr = 0x00050078;
232     cpu->isar.id_pfr0 = 0x111;
233     cpu->isar.id_pfr1 = 0x1;
234     cpu->isar.id_dfr0 = 0x2;
235     cpu->id_afr0 = 0x3;
236     cpu->isar.id_mmfr0 = 0x01130003;
237     cpu->isar.id_mmfr1 = 0x10030302;
238     cpu->isar.id_mmfr2 = 0x01222110;
239     cpu->isar.id_isar0 = 0x00140011;
240     cpu->isar.id_isar1 = 0x12002111;
241     cpu->isar.id_isar2 = 0x11231111;
242     cpu->isar.id_isar3 = 0x01102131;
243     cpu->isar.id_isar4 = 0x141;
244     cpu->reset_auxcr = 7;
245 }
246 
247 static void arm1176_initfn(Object *obj)
248 {
249     ARMCPU *cpu = ARM_CPU(obj);
250 
251     cpu->dtb_compatible = "arm,arm1176";
252     set_feature(&cpu->env, ARM_FEATURE_V6K);
253     set_feature(&cpu->env, ARM_FEATURE_VAPA);
254     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
255     set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG);
256     set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS);
257     set_feature(&cpu->env, ARM_FEATURE_EL3);
258     cpu->midr = 0x410fb767;
259     cpu->reset_fpsid = 0x410120b5;
260     cpu->isar.mvfr0 = 0x11111111;
261     cpu->isar.mvfr1 = 0x00000000;
262     cpu->ctr = 0x1dd20d2;
263     cpu->reset_sctlr = 0x00050078;
264     cpu->isar.id_pfr0 = 0x111;
265     cpu->isar.id_pfr1 = 0x11;
266     cpu->isar.id_dfr0 = 0x33;
267     cpu->id_afr0 = 0;
268     cpu->isar.id_mmfr0 = 0x01130003;
269     cpu->isar.id_mmfr1 = 0x10030302;
270     cpu->isar.id_mmfr2 = 0x01222100;
271     cpu->isar.id_isar0 = 0x0140011;
272     cpu->isar.id_isar1 = 0x12002111;
273     cpu->isar.id_isar2 = 0x11231121;
274     cpu->isar.id_isar3 = 0x01102131;
275     cpu->isar.id_isar4 = 0x01141;
276     cpu->reset_auxcr = 7;
277 }
278 
279 static void arm11mpcore_initfn(Object *obj)
280 {
281     ARMCPU *cpu = ARM_CPU(obj);
282 
283     cpu->dtb_compatible = "arm,arm11mpcore";
284     set_feature(&cpu->env, ARM_FEATURE_V6K);
285     set_feature(&cpu->env, ARM_FEATURE_VAPA);
286     set_feature(&cpu->env, ARM_FEATURE_MPIDR);
287     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
288     cpu->midr = 0x410fb022;
289     cpu->reset_fpsid = 0x410120b4;
290     cpu->isar.mvfr0 = 0x11111111;
291     cpu->isar.mvfr1 = 0x00000000;
292     cpu->ctr = 0x1d192992; /* 32K icache 32K dcache */
293     cpu->isar.id_pfr0 = 0x111;
294     cpu->isar.id_pfr1 = 0x1;
295     cpu->isar.id_dfr0 = 0;
296     cpu->id_afr0 = 0x2;
297     cpu->isar.id_mmfr0 = 0x01100103;
298     cpu->isar.id_mmfr1 = 0x10020302;
299     cpu->isar.id_mmfr2 = 0x01222000;
300     cpu->isar.id_isar0 = 0x00100011;
301     cpu->isar.id_isar1 = 0x12002111;
302     cpu->isar.id_isar2 = 0x11221011;
303     cpu->isar.id_isar3 = 0x01102131;
304     cpu->isar.id_isar4 = 0x141;
305     cpu->reset_auxcr = 1;
306 }
307 
308 static const ARMCPRegInfo cortexa8_cp_reginfo[] = {
309     { .name = "L2LOCKDOWN", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 0,
310       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
311     { .name = "L2AUXCR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2,
312       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
313 };
314 
315 static void cortex_a8_initfn(Object *obj)
316 {
317     ARMCPU *cpu = ARM_CPU(obj);
318 
319     cpu->dtb_compatible = "arm,cortex-a8";
320     set_feature(&cpu->env, ARM_FEATURE_V7);
321     set_feature(&cpu->env, ARM_FEATURE_NEON);
322     set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
323     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
324     set_feature(&cpu->env, ARM_FEATURE_EL3);
325     set_feature(&cpu->env, ARM_FEATURE_PMU);
326     cpu->midr = 0x410fc080;
327     cpu->reset_fpsid = 0x410330c0;
328     cpu->isar.mvfr0 = 0x11110222;
329     cpu->isar.mvfr1 = 0x00011111;
330     cpu->ctr = 0x82048004;
331     cpu->reset_sctlr = 0x00c50078;
332     cpu->isar.id_pfr0 = 0x1031;
333     cpu->isar.id_pfr1 = 0x11;
334     cpu->isar.id_dfr0 = 0x400;
335     cpu->id_afr0 = 0;
336     cpu->isar.id_mmfr0 = 0x31100003;
337     cpu->isar.id_mmfr1 = 0x20000000;
338     cpu->isar.id_mmfr2 = 0x01202000;
339     cpu->isar.id_mmfr3 = 0x11;
340     cpu->isar.id_isar0 = 0x00101111;
341     cpu->isar.id_isar1 = 0x12112111;
342     cpu->isar.id_isar2 = 0x21232031;
343     cpu->isar.id_isar3 = 0x11112131;
344     cpu->isar.id_isar4 = 0x00111142;
345     cpu->isar.dbgdidr = 0x15141000;
346     cpu->clidr = (1 << 27) | (2 << 24) | 3;
347     cpu->ccsidr[0] = 0xe007e01a; /* 16k L1 dcache. */
348     cpu->ccsidr[1] = 0x2007e01a; /* 16k L1 icache. */
349     cpu->ccsidr[2] = 0xf0000000; /* No L2 icache. */
350     cpu->reset_auxcr = 2;
351     cpu->isar.reset_pmcr_el0 = 0x41002000;
352     define_arm_cp_regs(cpu, cortexa8_cp_reginfo);
353 }
354 
355 static const ARMCPRegInfo cortexa9_cp_reginfo[] = {
356     /*
357      * power_control should be set to maximum latency. Again,
358      * default to 0 and set by private hook
359      */
360     { .name = "A9_PWRCTL", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 0,
361       .access = PL1_RW, .resetvalue = 0,
362       .fieldoffset = offsetof(CPUARMState, cp15.c15_power_control) },
363     { .name = "A9_DIAG", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 1,
364       .access = PL1_RW, .resetvalue = 0,
365       .fieldoffset = offsetof(CPUARMState, cp15.c15_diagnostic) },
366     { .name = "A9_PWRDIAG", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 2,
367       .access = PL1_RW, .resetvalue = 0,
368       .fieldoffset = offsetof(CPUARMState, cp15.c15_power_diagnostic) },
369     { .name = "NEONBUSY", .cp = 15, .crn = 15, .crm = 1, .opc1 = 0, .opc2 = 0,
370       .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
371     /* TLB lockdown control */
372     { .name = "TLB_LOCKR", .cp = 15, .crn = 15, .crm = 4, .opc1 = 5, .opc2 = 2,
373       .access = PL1_W, .resetvalue = 0, .type = ARM_CP_NOP },
374     { .name = "TLB_LOCKW", .cp = 15, .crn = 15, .crm = 4, .opc1 = 5, .opc2 = 4,
375       .access = PL1_W, .resetvalue = 0, .type = ARM_CP_NOP },
376     { .name = "TLB_VA", .cp = 15, .crn = 15, .crm = 5, .opc1 = 5, .opc2 = 2,
377       .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
378     { .name = "TLB_PA", .cp = 15, .crn = 15, .crm = 6, .opc1 = 5, .opc2 = 2,
379       .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
380     { .name = "TLB_ATTR", .cp = 15, .crn = 15, .crm = 7, .opc1 = 5, .opc2 = 2,
381       .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
382 };
383 
384 static void cortex_a9_initfn(Object *obj)
385 {
386     ARMCPU *cpu = ARM_CPU(obj);
387 
388     cpu->dtb_compatible = "arm,cortex-a9";
389     set_feature(&cpu->env, ARM_FEATURE_V7);
390     set_feature(&cpu->env, ARM_FEATURE_NEON);
391     set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
392     set_feature(&cpu->env, ARM_FEATURE_EL3);
393     set_feature(&cpu->env, ARM_FEATURE_PMU);
394     /*
395      * Note that A9 supports the MP extensions even for
396      * A9UP and single-core A9MP (which are both different
397      * and valid configurations; we don't model A9UP).
398      */
399     set_feature(&cpu->env, ARM_FEATURE_V7MP);
400     set_feature(&cpu->env, ARM_FEATURE_CBAR);
401     cpu->midr = 0x410fc090;
402     cpu->reset_fpsid = 0x41033090;
403     cpu->isar.mvfr0 = 0x11110222;
404     cpu->isar.mvfr1 = 0x01111111;
405     cpu->ctr = 0x80038003;
406     cpu->reset_sctlr = 0x00c50078;
407     cpu->isar.id_pfr0 = 0x1031;
408     cpu->isar.id_pfr1 = 0x11;
409     cpu->isar.id_dfr0 = 0x000;
410     cpu->id_afr0 = 0;
411     cpu->isar.id_mmfr0 = 0x00100103;
412     cpu->isar.id_mmfr1 = 0x20000000;
413     cpu->isar.id_mmfr2 = 0x01230000;
414     cpu->isar.id_mmfr3 = 0x00002111;
415     cpu->isar.id_isar0 = 0x00101111;
416     cpu->isar.id_isar1 = 0x13112111;
417     cpu->isar.id_isar2 = 0x21232041;
418     cpu->isar.id_isar3 = 0x11112131;
419     cpu->isar.id_isar4 = 0x00111142;
420     cpu->isar.dbgdidr = 0x35141000;
421     cpu->clidr = (1 << 27) | (1 << 24) | 3;
422     cpu->ccsidr[0] = 0xe00fe019; /* 16k L1 dcache. */
423     cpu->ccsidr[1] = 0x200fe019; /* 16k L1 icache. */
424     cpu->isar.reset_pmcr_el0 = 0x41093000;
425     define_arm_cp_regs(cpu, cortexa9_cp_reginfo);
426 }
427 
428 #ifndef CONFIG_USER_ONLY
429 static uint64_t a15_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
430 {
431     MachineState *ms = MACHINE(qdev_get_machine());
432 
433     /*
434      * Linux wants the number of processors from here.
435      * Might as well set the interrupt-controller bit too.
436      */
437     return ((ms->smp.cpus - 1) << 24) | (1 << 23);
438 }
439 #endif
440 
441 static const ARMCPRegInfo cortexa15_cp_reginfo[] = {
442 #ifndef CONFIG_USER_ONLY
443     { .name = "L2CTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2,
444       .access = PL1_RW, .resetvalue = 0, .readfn = a15_l2ctlr_read,
445       .writefn = arm_cp_write_ignore, },
446 #endif
447     { .name = "L2ECTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 3,
448       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
449 };
450 
451 static void cortex_a7_initfn(Object *obj)
452 {
453     ARMCPU *cpu = ARM_CPU(obj);
454 
455     cpu->dtb_compatible = "arm,cortex-a7";
456     set_feature(&cpu->env, ARM_FEATURE_V7VE);
457     set_feature(&cpu->env, ARM_FEATURE_NEON);
458     set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
459     set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
460     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
461     set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
462     set_feature(&cpu->env, ARM_FEATURE_EL2);
463     set_feature(&cpu->env, ARM_FEATURE_EL3);
464     set_feature(&cpu->env, ARM_FEATURE_PMU);
465     cpu->midr = 0x410fc075;
466     cpu->reset_fpsid = 0x41023075;
467     cpu->isar.mvfr0 = 0x10110222;
468     cpu->isar.mvfr1 = 0x11111111;
469     cpu->ctr = 0x84448003;
470     cpu->reset_sctlr = 0x00c50078;
471     cpu->isar.id_pfr0 = 0x00001131;
472     cpu->isar.id_pfr1 = 0x00011011;
473     cpu->isar.id_dfr0 = 0x02010555;
474     cpu->id_afr0 = 0x00000000;
475     cpu->isar.id_mmfr0 = 0x10101105;
476     cpu->isar.id_mmfr1 = 0x40000000;
477     cpu->isar.id_mmfr2 = 0x01240000;
478     cpu->isar.id_mmfr3 = 0x02102211;
479     /*
480      * a7_mpcore_r0p5_trm, page 4-4 gives 0x01101110; but
481      * table 4-41 gives 0x02101110, which includes the arm div insns.
482      */
483     cpu->isar.id_isar0 = 0x02101110;
484     cpu->isar.id_isar1 = 0x13112111;
485     cpu->isar.id_isar2 = 0x21232041;
486     cpu->isar.id_isar3 = 0x11112131;
487     cpu->isar.id_isar4 = 0x10011142;
488     cpu->isar.dbgdidr = 0x3515f005;
489     cpu->isar.dbgdevid = 0x01110f13;
490     cpu->isar.dbgdevid1 = 0x1;
491     cpu->clidr = 0x0a200023;
492     cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */
493     cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */
494     cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
495     cpu->isar.reset_pmcr_el0 = 0x41072000;
496     define_arm_cp_regs(cpu, cortexa15_cp_reginfo); /* Same as A15 */
497 }
498 
499 static void cortex_a15_initfn(Object *obj)
500 {
501     ARMCPU *cpu = ARM_CPU(obj);
502 
503     cpu->dtb_compatible = "arm,cortex-a15";
504     set_feature(&cpu->env, ARM_FEATURE_V7VE);
505     set_feature(&cpu->env, ARM_FEATURE_NEON);
506     set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
507     set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
508     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
509     set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
510     set_feature(&cpu->env, ARM_FEATURE_EL2);
511     set_feature(&cpu->env, ARM_FEATURE_EL3);
512     set_feature(&cpu->env, ARM_FEATURE_PMU);
513     /* r4p0 cpu, not requiring expensive tlb flush errata */
514     cpu->midr = 0x414fc0f0;
515     cpu->revidr = 0x0;
516     cpu->reset_fpsid = 0x410430f0;
517     cpu->isar.mvfr0 = 0x10110222;
518     cpu->isar.mvfr1 = 0x11111111;
519     cpu->ctr = 0x8444c004;
520     cpu->reset_sctlr = 0x00c50078;
521     cpu->isar.id_pfr0 = 0x00001131;
522     cpu->isar.id_pfr1 = 0x00011011;
523     cpu->isar.id_dfr0 = 0x02010555;
524     cpu->id_afr0 = 0x00000000;
525     cpu->isar.id_mmfr0 = 0x10201105;
526     cpu->isar.id_mmfr1 = 0x20000000;
527     cpu->isar.id_mmfr2 = 0x01240000;
528     cpu->isar.id_mmfr3 = 0x02102211;
529     cpu->isar.id_isar0 = 0x02101110;
530     cpu->isar.id_isar1 = 0x13112111;
531     cpu->isar.id_isar2 = 0x21232041;
532     cpu->isar.id_isar3 = 0x11112131;
533     cpu->isar.id_isar4 = 0x10011142;
534     cpu->isar.dbgdidr = 0x3515f021;
535     cpu->isar.dbgdevid = 0x01110f13;
536     cpu->isar.dbgdevid1 = 0x0;
537     cpu->clidr = 0x0a200023;
538     cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */
539     cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */
540     cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
541     cpu->isar.reset_pmcr_el0 = 0x410F3000;
542     define_arm_cp_regs(cpu, cortexa15_cp_reginfo);
543 }
544 
545 static const ARMCPRegInfo cortexr5_cp_reginfo[] = {
546     /* Dummy the TCM region regs for the moment */
547     { .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0,
548       .access = PL1_RW, .type = ARM_CP_CONST },
549     { .name = "BTCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 1,
550       .access = PL1_RW, .type = ARM_CP_CONST },
551     { .name = "DCACHE_INVAL", .cp = 15, .opc1 = 0, .crn = 15, .crm = 5,
552       .opc2 = 0, .access = PL1_W, .type = ARM_CP_NOP },
553 };
554 
555 static void cortex_r5_initfn(Object *obj)
556 {
557     ARMCPU *cpu = ARM_CPU(obj);
558 
559     set_feature(&cpu->env, ARM_FEATURE_V7);
560     set_feature(&cpu->env, ARM_FEATURE_V7MP);
561     set_feature(&cpu->env, ARM_FEATURE_PMSA);
562     set_feature(&cpu->env, ARM_FEATURE_PMU);
563     cpu->midr = 0x411fc153; /* r1p3 */
564     cpu->isar.id_pfr0 = 0x0131;
565     cpu->isar.id_pfr1 = 0x001;
566     cpu->isar.id_dfr0 = 0x010400;
567     cpu->id_afr0 = 0x0;
568     cpu->isar.id_mmfr0 = 0x0210030;
569     cpu->isar.id_mmfr1 = 0x00000000;
570     cpu->isar.id_mmfr2 = 0x01200000;
571     cpu->isar.id_mmfr3 = 0x0211;
572     cpu->isar.id_isar0 = 0x02101111;
573     cpu->isar.id_isar1 = 0x13112111;
574     cpu->isar.id_isar2 = 0x21232141;
575     cpu->isar.id_isar3 = 0x01112131;
576     cpu->isar.id_isar4 = 0x0010142;
577     cpu->isar.id_isar5 = 0x0;
578     cpu->isar.id_isar6 = 0x0;
579     cpu->mp_is_up = true;
580     cpu->pmsav7_dregion = 16;
581     cpu->isar.reset_pmcr_el0 = 0x41151800;
582     define_arm_cp_regs(cpu, cortexr5_cp_reginfo);
583 }
584 
585 static const ARMCPRegInfo cortex_r52_cp_reginfo[] = {
586     { .name = "CPUACTLR", .cp = 15, .opc1 = 0, .crm = 15,
587       .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
588     { .name = "IMP_ATCMREGIONR",
589       .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0,
590       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
591     { .name = "IMP_BTCMREGIONR",
592       .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 1,
593       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
594     { .name = "IMP_CTCMREGIONR",
595       .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 2,
596       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
597     { .name = "IMP_CSCTLR",
598       .cp = 15, .opc1 = 1, .crn = 9, .crm = 1, .opc2 = 0,
599       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
600     { .name = "IMP_BPCTLR",
601       .cp = 15, .opc1 = 1, .crn = 9, .crm = 1, .opc2 = 1,
602       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
603     { .name = "IMP_MEMPROTCLR",
604       .cp = 15, .opc1 = 1, .crn = 9, .crm = 1, .opc2 = 2,
605       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
606     { .name = "IMP_SLAVEPCTLR",
607       .cp = 15, .opc1 = 0, .crn = 11, .crm = 0, .opc2 = 0,
608       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
609     { .name = "IMP_PERIPHREGIONR",
610       .cp = 15, .opc1 = 0, .crn = 15, .crm = 0, .opc2 = 0,
611       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
612     { .name = "IMP_FLASHIFREGIONR",
613       .cp = 15, .opc1 = 0, .crn = 15, .crm = 0, .opc2 = 1,
614       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
615     { .name = "IMP_BUILDOPTR",
616       .cp = 15, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 0,
617       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
618     { .name = "IMP_PINOPTR",
619       .cp = 15, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 7,
620       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
621     { .name = "IMP_QOSR",
622       .cp = 15, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 1,
623       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
624     { .name = "IMP_BUSTIMEOUTR",
625       .cp = 15, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 2,
626       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
627     { .name = "IMP_INTMONR",
628       .cp = 15, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 4,
629       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
630     { .name = "IMP_ICERR0",
631       .cp = 15, .opc1 = 2, .crn = 15, .crm = 0, .opc2 = 0,
632       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
633     { .name = "IMP_ICERR1",
634       .cp = 15, .opc1 = 2, .crn = 15, .crm = 0, .opc2 = 1,
635       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
636     { .name = "IMP_DCERR0",
637       .cp = 15, .opc1 = 2, .crn = 15, .crm = 1, .opc2 = 0,
638       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
639     { .name = "IMP_DCERR1",
640       .cp = 15, .opc1 = 2, .crn = 15, .crm = 1, .opc2 = 1,
641       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
642     { .name = "IMP_TCMERR0",
643       .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 0,
644       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
645     { .name = "IMP_TCMERR1",
646       .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 1,
647       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
648     { .name = "IMP_TCMSYNDR0",
649       .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 2,
650       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
651     { .name = "IMP_TCMSYNDR1",
652       .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 3,
653       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
654     { .name = "IMP_FLASHERR0",
655       .cp = 15, .opc1 = 2, .crn = 15, .crm = 3, .opc2 = 0,
656       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
657     { .name = "IMP_FLASHERR1",
658       .cp = 15, .opc1 = 2, .crn = 15, .crm = 3, .opc2 = 1,
659       .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
660     { .name = "IMP_CDBGDR0",
661       .cp = 15, .opc1 = 3, .crn = 15, .crm = 0, .opc2 = 0,
662       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
663     { .name = "IMP_CBDGBR1",
664       .cp = 15, .opc1 = 3, .crn = 15, .crm = 0, .opc2 = 1,
665       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
666     { .name = "IMP_TESTR0",
667       .cp = 15, .opc1 = 4, .crn = 15, .crm = 0, .opc2 = 0,
668       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
669     { .name = "IMP_TESTR1",
670       .cp = 15, .opc1 = 4, .crn = 15, .crm = 0, .opc2 = 1,
671       .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
672     { .name = "IMP_CDBGDCI",
673       .cp = 15, .opc1 = 0, .crn = 15, .crm = 15, .opc2 = 0,
674       .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
675     { .name = "IMP_CDBGDCT",
676       .cp = 15, .opc1 = 3, .crn = 15, .crm = 2, .opc2 = 0,
677       .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
678     { .name = "IMP_CDBGICT",
679       .cp = 15, .opc1 = 3, .crn = 15, .crm = 2, .opc2 = 1,
680       .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
681     { .name = "IMP_CDBGDCD",
682       .cp = 15, .opc1 = 3, .crn = 15, .crm = 4, .opc2 = 0,
683       .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
684     { .name = "IMP_CDBGICD",
685       .cp = 15, .opc1 = 3, .crn = 15, .crm = 4, .opc2 = 1,
686       .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 },
687 };
688 
689 
690 static void cortex_r52_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_EL2);
696     set_feature(&cpu->env, ARM_FEATURE_PMSA);
697     set_feature(&cpu->env, ARM_FEATURE_NEON);
698     set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
699     set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
700     set_feature(&cpu->env, ARM_FEATURE_AUXCR);
701     cpu->midr = 0x411fd133; /* r1p3 */
702     cpu->revidr = 0x00000000;
703     cpu->reset_fpsid = 0x41034023;
704     cpu->isar.mvfr0 = 0x10110222;
705     cpu->isar.mvfr1 = 0x12111111;
706     cpu->isar.mvfr2 = 0x00000043;
707     cpu->ctr = 0x8144c004;
708     cpu->reset_sctlr = 0x30c50838;
709     cpu->isar.id_pfr0 = 0x00000131;
710     cpu->isar.id_pfr1 = 0x10111001;
711     cpu->isar.id_dfr0 = 0x03010006;
712     cpu->id_afr0 = 0x00000000;
713     cpu->isar.id_mmfr0 = 0x00211040;
714     cpu->isar.id_mmfr1 = 0x40000000;
715     cpu->isar.id_mmfr2 = 0x01200000;
716     cpu->isar.id_mmfr3 = 0xf0102211;
717     cpu->isar.id_mmfr4 = 0x00000010;
718     cpu->isar.id_isar0 = 0x02101110;
719     cpu->isar.id_isar1 = 0x13112111;
720     cpu->isar.id_isar2 = 0x21232142;
721     cpu->isar.id_isar3 = 0x01112131;
722     cpu->isar.id_isar4 = 0x00010142;
723     cpu->isar.id_isar5 = 0x00010001;
724     cpu->isar.dbgdidr = 0x77168000;
725     cpu->clidr = (1 << 27) | (1 << 24) | 0x3;
726     cpu->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */
727     cpu->ccsidr[1] = 0x201fe00a; /* 32KB L1 icache */
728 
729     cpu->pmsav7_dregion = 16;
730     cpu->pmsav8r_hdregion = 16;
731 
732     define_arm_cp_regs(cpu, cortex_r52_cp_reginfo);
733 }
734 
735 static void cortex_r5f_initfn(Object *obj)
736 {
737     ARMCPU *cpu = ARM_CPU(obj);
738 
739     cortex_r5_initfn(obj);
740     cpu->isar.mvfr0 = 0x10110221;
741     cpu->isar.mvfr1 = 0x00000011;
742 }
743 
744 static void ti925t_initfn(Object *obj)
745 {
746     ARMCPU *cpu = ARM_CPU(obj);
747     set_feature(&cpu->env, ARM_FEATURE_V4T);
748     set_feature(&cpu->env, ARM_FEATURE_OMAPCP);
749     cpu->midr = ARM_CPUID_TI925T;
750     cpu->ctr = 0x5109149;
751     cpu->reset_sctlr = 0x00000070;
752 }
753 
754 static void sa1100_initfn(Object *obj)
755 {
756     ARMCPU *cpu = ARM_CPU(obj);
757 
758     cpu->dtb_compatible = "intel,sa1100";
759     set_feature(&cpu->env, ARM_FEATURE_STRONGARM);
760     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
761     cpu->midr = 0x4401A11B;
762     cpu->reset_sctlr = 0x00000070;
763 }
764 
765 static void sa1110_initfn(Object *obj)
766 {
767     ARMCPU *cpu = ARM_CPU(obj);
768     set_feature(&cpu->env, ARM_FEATURE_STRONGARM);
769     set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
770     cpu->midr = 0x6901B119;
771     cpu->reset_sctlr = 0x00000070;
772 }
773 
774 static void pxa250_initfn(Object *obj)
775 {
776     ARMCPU *cpu = ARM_CPU(obj);
777 
778     cpu->dtb_compatible = "marvell,xscale";
779     set_feature(&cpu->env, ARM_FEATURE_V5);
780     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
781     cpu->midr = 0x69052100;
782     cpu->ctr = 0xd172172;
783     cpu->reset_sctlr = 0x00000078;
784 }
785 
786 static void pxa255_initfn(Object *obj)
787 {
788     ARMCPU *cpu = ARM_CPU(obj);
789 
790     cpu->dtb_compatible = "marvell,xscale";
791     set_feature(&cpu->env, ARM_FEATURE_V5);
792     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
793     cpu->midr = 0x69052d00;
794     cpu->ctr = 0xd172172;
795     cpu->reset_sctlr = 0x00000078;
796 }
797 
798 static void pxa260_initfn(Object *obj)
799 {
800     ARMCPU *cpu = ARM_CPU(obj);
801 
802     cpu->dtb_compatible = "marvell,xscale";
803     set_feature(&cpu->env, ARM_FEATURE_V5);
804     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
805     cpu->midr = 0x69052903;
806     cpu->ctr = 0xd172172;
807     cpu->reset_sctlr = 0x00000078;
808 }
809 
810 static void pxa261_initfn(Object *obj)
811 {
812     ARMCPU *cpu = ARM_CPU(obj);
813 
814     cpu->dtb_compatible = "marvell,xscale";
815     set_feature(&cpu->env, ARM_FEATURE_V5);
816     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
817     cpu->midr = 0x69052d05;
818     cpu->ctr = 0xd172172;
819     cpu->reset_sctlr = 0x00000078;
820 }
821 
822 static void pxa262_initfn(Object *obj)
823 {
824     ARMCPU *cpu = ARM_CPU(obj);
825 
826     cpu->dtb_compatible = "marvell,xscale";
827     set_feature(&cpu->env, ARM_FEATURE_V5);
828     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
829     cpu->midr = 0x69052d06;
830     cpu->ctr = 0xd172172;
831     cpu->reset_sctlr = 0x00000078;
832 }
833 
834 static void pxa270a0_initfn(Object *obj)
835 {
836     ARMCPU *cpu = ARM_CPU(obj);
837 
838     cpu->dtb_compatible = "marvell,xscale";
839     set_feature(&cpu->env, ARM_FEATURE_V5);
840     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
841     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
842     cpu->midr = 0x69054110;
843     cpu->ctr = 0xd172172;
844     cpu->reset_sctlr = 0x00000078;
845 }
846 
847 static void pxa270a1_initfn(Object *obj)
848 {
849     ARMCPU *cpu = ARM_CPU(obj);
850 
851     cpu->dtb_compatible = "marvell,xscale";
852     set_feature(&cpu->env, ARM_FEATURE_V5);
853     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
854     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
855     cpu->midr = 0x69054111;
856     cpu->ctr = 0xd172172;
857     cpu->reset_sctlr = 0x00000078;
858 }
859 
860 static void pxa270b0_initfn(Object *obj)
861 {
862     ARMCPU *cpu = ARM_CPU(obj);
863 
864     cpu->dtb_compatible = "marvell,xscale";
865     set_feature(&cpu->env, ARM_FEATURE_V5);
866     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
867     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
868     cpu->midr = 0x69054112;
869     cpu->ctr = 0xd172172;
870     cpu->reset_sctlr = 0x00000078;
871 }
872 
873 static void pxa270b1_initfn(Object *obj)
874 {
875     ARMCPU *cpu = ARM_CPU(obj);
876 
877     cpu->dtb_compatible = "marvell,xscale";
878     set_feature(&cpu->env, ARM_FEATURE_V5);
879     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
880     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
881     cpu->midr = 0x69054113;
882     cpu->ctr = 0xd172172;
883     cpu->reset_sctlr = 0x00000078;
884 }
885 
886 static void pxa270c0_initfn(Object *obj)
887 {
888     ARMCPU *cpu = ARM_CPU(obj);
889 
890     cpu->dtb_compatible = "marvell,xscale";
891     set_feature(&cpu->env, ARM_FEATURE_V5);
892     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
893     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
894     cpu->midr = 0x69054114;
895     cpu->ctr = 0xd172172;
896     cpu->reset_sctlr = 0x00000078;
897 }
898 
899 static void pxa270c5_initfn(Object *obj)
900 {
901     ARMCPU *cpu = ARM_CPU(obj);
902 
903     cpu->dtb_compatible = "marvell,xscale";
904     set_feature(&cpu->env, ARM_FEATURE_V5);
905     set_feature(&cpu->env, ARM_FEATURE_XSCALE);
906     set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
907     cpu->midr = 0x69054117;
908     cpu->ctr = 0xd172172;
909     cpu->reset_sctlr = 0x00000078;
910 }
911 
912 #ifndef TARGET_AARCH64
913 /*
914  * -cpu max: a CPU with as many features enabled as our emulation supports.
915  * The version of '-cpu max' for qemu-system-aarch64 is defined in cpu64.c;
916  * this only needs to handle 32 bits, and need not care about KVM.
917  */
918 static void arm_max_initfn(Object *obj)
919 {
920     ARMCPU *cpu = ARM_CPU(obj);
921 
922     /* aarch64_a57_initfn, advertising none of the aarch64 features */
923     cpu->dtb_compatible = "arm,cortex-a57";
924     set_feature(&cpu->env, ARM_FEATURE_V8);
925     set_feature(&cpu->env, ARM_FEATURE_NEON);
926     set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
927     set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
928     set_feature(&cpu->env, ARM_FEATURE_EL2);
929     set_feature(&cpu->env, ARM_FEATURE_EL3);
930     set_feature(&cpu->env, ARM_FEATURE_PMU);
931     cpu->midr = 0x411fd070;
932     cpu->revidr = 0x00000000;
933     cpu->reset_fpsid = 0x41034070;
934     cpu->isar.mvfr0 = 0x10110222;
935     cpu->isar.mvfr1 = 0x12111111;
936     cpu->isar.mvfr2 = 0x00000043;
937     cpu->ctr = 0x8444c004;
938     cpu->reset_sctlr = 0x00c50838;
939     cpu->isar.id_pfr0 = 0x00000131;
940     cpu->isar.id_pfr1 = 0x00011011;
941     cpu->isar.id_dfr0 = 0x03010066;
942     cpu->id_afr0 = 0x00000000;
943     cpu->isar.id_mmfr0 = 0x10101105;
944     cpu->isar.id_mmfr1 = 0x40000000;
945     cpu->isar.id_mmfr2 = 0x01260000;
946     cpu->isar.id_mmfr3 = 0x02102211;
947     cpu->isar.id_isar0 = 0x02101110;
948     cpu->isar.id_isar1 = 0x13112111;
949     cpu->isar.id_isar2 = 0x21232042;
950     cpu->isar.id_isar3 = 0x01112131;
951     cpu->isar.id_isar4 = 0x00011142;
952     cpu->isar.id_isar5 = 0x00011121;
953     cpu->isar.id_isar6 = 0;
954     cpu->isar.dbgdidr = 0x3516d000;
955     cpu->isar.dbgdevid = 0x00110f13;
956     cpu->isar.dbgdevid1 = 0x2;
957     cpu->isar.reset_pmcr_el0 = 0x41013000;
958     cpu->clidr = 0x0a200023;
959     cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */
960     cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */
961     cpu->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */
962     define_cortex_a72_a57_a53_cp_reginfo(cpu);
963 
964     aa32_max_features(cpu);
965 
966 #ifdef CONFIG_USER_ONLY
967     /*
968      * Break with true ARMv8 and add back old-style VFP short-vector support.
969      * Only do this for user-mode, where -cpu max is the default, so that
970      * older v6 and v7 programs are more likely to work without adjustment.
971      */
972     cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
973 #endif
974 }
975 #endif /* !TARGET_AARCH64 */
976 
977 static const ARMCPUInfo arm_tcg_cpus[] = {
978     { .name = "arm926",      .initfn = arm926_initfn },
979     { .name = "arm946",      .initfn = arm946_initfn },
980     { .name = "arm1026",     .initfn = arm1026_initfn },
981     /*
982      * What QEMU calls "arm1136-r2" is actually the 1136 r0p2, i.e. an
983      * older core than plain "arm1136". In particular this does not
984      * have the v6K features.
985      */
986     { .name = "arm1136-r2",  .initfn = arm1136_r2_initfn },
987     { .name = "arm1136",     .initfn = arm1136_initfn },
988     { .name = "arm1176",     .initfn = arm1176_initfn },
989     { .name = "arm11mpcore", .initfn = arm11mpcore_initfn },
990     { .name = "cortex-a7",   .initfn = cortex_a7_initfn },
991     { .name = "cortex-a8",   .initfn = cortex_a8_initfn },
992     { .name = "cortex-a9",   .initfn = cortex_a9_initfn },
993     { .name = "cortex-a15",  .initfn = cortex_a15_initfn },
994     { .name = "cortex-r5",   .initfn = cortex_r5_initfn },
995     { .name = "cortex-r5f",  .initfn = cortex_r5f_initfn },
996     { .name = "cortex-r52",  .initfn = cortex_r52_initfn },
997     { .name = "ti925t",      .initfn = ti925t_initfn },
998     { .name = "sa1100",      .initfn = sa1100_initfn },
999     { .name = "sa1110",      .initfn = sa1110_initfn },
1000     { .name = "pxa250",      .initfn = pxa250_initfn },
1001     { .name = "pxa255",      .initfn = pxa255_initfn },
1002     { .name = "pxa260",      .initfn = pxa260_initfn },
1003     { .name = "pxa261",      .initfn = pxa261_initfn },
1004     { .name = "pxa262",      .initfn = pxa262_initfn },
1005     /* "pxa270" is an alias for "pxa270-a0" */
1006     { .name = "pxa270",      .initfn = pxa270a0_initfn },
1007     { .name = "pxa270-a0",   .initfn = pxa270a0_initfn },
1008     { .name = "pxa270-a1",   .initfn = pxa270a1_initfn },
1009     { .name = "pxa270-b0",   .initfn = pxa270b0_initfn },
1010     { .name = "pxa270-b1",   .initfn = pxa270b1_initfn },
1011     { .name = "pxa270-c0",   .initfn = pxa270c0_initfn },
1012     { .name = "pxa270-c5",   .initfn = pxa270c5_initfn },
1013 #ifndef TARGET_AARCH64
1014     { .name = "max",         .initfn = arm_max_initfn },
1015 #endif
1016 #ifdef CONFIG_USER_ONLY
1017     { .name = "any",         .initfn = arm_max_initfn },
1018 #endif
1019 };
1020 
1021 static const TypeInfo idau_interface_type_info = {
1022     .name = TYPE_IDAU_INTERFACE,
1023     .parent = TYPE_INTERFACE,
1024     .class_size = sizeof(IDAUInterfaceClass),
1025 };
1026 
1027 static void arm_tcg_cpu_register_types(void)
1028 {
1029     size_t i;
1030 
1031     type_register_static(&idau_interface_type_info);
1032     for (i = 0; i < ARRAY_SIZE(arm_tcg_cpus); ++i) {
1033         arm_cpu_register(&arm_tcg_cpus[i]);
1034     }
1035 }
1036 
1037 type_init(arm_tcg_cpu_register_types)
1038 
1039 #endif /* !CONFIG_USER_ONLY || !TARGET_AARCH64 */
1040