~ubuntu-branches/ubuntu/utopic/qemu/utopic

« back to all changes in this revision

Viewing changes to .pc/arm64/0009-target-arm-Don-t-hardcode-KVM-target-CPU-to-be-A15.patch/target-arm/cpu.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn, Serge Hallyn, dann frazier
  • Date: 2014-01-10 12:19:08 UTC
  • Revision ID: package-import@ubuntu.com-20140110121908-6lsn06rypqbokbaf
Tags: 1.7.0+dfsg-2ubuntu6
[ Serge Hallyn ]
* add arm64 patchset from upstream.  The three arm virt patches previously
  pushed are in that set, so drop them.

[ dann frazier ]
* Add packaging for qemu-system-aarch64. This package is currently only
  available for arm64, as full software emulation is not yet supported.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * QEMU ARM CPU
 
3
 *
 
4
 * Copyright (c) 2012 SUSE LINUX Products GmbH
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License
 
8
 * as published by the Free Software Foundation; either version 2
 
9
 * of the License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, see
 
18
 * <http://www.gnu.org/licenses/gpl-2.0.html>
 
19
 */
 
20
 
 
21
#include "cpu.h"
 
22
#include "qemu-common.h"
 
23
#include "hw/qdev-properties.h"
 
24
#if !defined(CONFIG_USER_ONLY)
 
25
#include "hw/loader.h"
 
26
#endif
 
27
#include "hw/arm/arm.h"
 
28
#include "sysemu/sysemu.h"
 
29
#include "sysemu/kvm.h"
 
30
 
 
31
static void arm_cpu_set_pc(CPUState *cs, vaddr value)
 
32
{
 
33
    ARMCPU *cpu = ARM_CPU(cs);
 
34
 
 
35
    cpu->env.regs[15] = value;
 
36
}
 
37
 
 
38
static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque)
 
39
{
 
40
    /* Reset a single ARMCPRegInfo register */
 
41
    ARMCPRegInfo *ri = value;
 
42
    ARMCPU *cpu = opaque;
 
43
 
 
44
    if (ri->type & ARM_CP_SPECIAL) {
 
45
        return;
 
46
    }
 
47
 
 
48
    if (ri->resetfn) {
 
49
        ri->resetfn(&cpu->env, ri);
 
50
        return;
 
51
    }
 
52
 
 
53
    /* A zero offset is never possible as it would be regs[0]
 
54
     * so we use it to indicate that reset is being handled elsewhere.
 
55
     * This is basically only used for fields in non-core coprocessors
 
56
     * (like the pxa2xx ones).
 
57
     */
 
58
    if (!ri->fieldoffset) {
 
59
        return;
 
60
    }
 
61
 
 
62
    if (ri->type & ARM_CP_64BIT) {
 
63
        CPREG_FIELD64(&cpu->env, ri) = ri->resetvalue;
 
64
    } else {
 
65
        CPREG_FIELD32(&cpu->env, ri) = ri->resetvalue;
 
66
    }
 
67
}
 
68
 
 
69
/* CPUClass::reset() */
 
70
static void arm_cpu_reset(CPUState *s)
 
71
{
 
72
    ARMCPU *cpu = ARM_CPU(s);
 
73
    ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu);
 
74
    CPUARMState *env = &cpu->env;
 
75
 
 
76
    acc->parent_reset(s);
 
77
 
 
78
    memset(env, 0, offsetof(CPUARMState, breakpoints));
 
79
    g_hash_table_foreach(cpu->cp_regs, cp_reg_reset, cpu);
 
80
    env->vfp.xregs[ARM_VFP_FPSID] = cpu->reset_fpsid;
 
81
    env->vfp.xregs[ARM_VFP_MVFR0] = cpu->mvfr0;
 
82
    env->vfp.xregs[ARM_VFP_MVFR1] = cpu->mvfr1;
 
83
 
 
84
    if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
 
85
        env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';
 
86
    }
 
87
 
 
88
    if (arm_feature(env, ARM_FEATURE_AARCH64)) {
 
89
        /* 64 bit CPUs always start in 64 bit mode */
 
90
        env->aarch64 = 1;
 
91
    }
 
92
 
 
93
#if defined(CONFIG_USER_ONLY)
 
94
    env->uncached_cpsr = ARM_CPU_MODE_USR;
 
95
    /* For user mode we must enable access to coprocessors */
 
96
    env->vfp.xregs[ARM_VFP_FPEXC] = 1 << 30;
 
97
    if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
 
98
        env->cp15.c15_cpar = 3;
 
99
    } else if (arm_feature(env, ARM_FEATURE_XSCALE)) {
 
100
        env->cp15.c15_cpar = 1;
 
101
    }
 
102
#else
 
103
    /* SVC mode with interrupts disabled.  */
 
104
    env->uncached_cpsr = ARM_CPU_MODE_SVC | CPSR_A | CPSR_F | CPSR_I;
 
105
    /* On ARMv7-M the CPSR_I is the value of the PRIMASK register, and is
 
106
       clear at reset.  Initial SP and PC are loaded from ROM.  */
 
107
    if (IS_M(env)) {
 
108
        uint32_t pc;
 
109
        uint8_t *rom;
 
110
        env->uncached_cpsr &= ~CPSR_I;
 
111
        rom = rom_ptr(0);
 
112
        if (rom) {
 
113
            /* We should really use ldl_phys here, in case the guest
 
114
               modified flash and reset itself.  However images
 
115
               loaded via -kernel have not been copied yet, so load the
 
116
               values directly from there.  */
 
117
            env->regs[13] = ldl_p(rom) & 0xFFFFFFFC;
 
118
            pc = ldl_p(rom + 4);
 
119
            env->thumb = pc & 1;
 
120
            env->regs[15] = pc & ~1;
 
121
        }
 
122
    }
 
123
    env->vfp.xregs[ARM_VFP_FPEXC] = 0;
 
124
#endif
 
125
    set_flush_to_zero(1, &env->vfp.standard_fp_status);
 
126
    set_flush_inputs_to_zero(1, &env->vfp.standard_fp_status);
 
127
    set_default_nan_mode(1, &env->vfp.standard_fp_status);
 
128
    set_float_detect_tininess(float_tininess_before_rounding,
 
129
                              &env->vfp.fp_status);
 
130
    set_float_detect_tininess(float_tininess_before_rounding,
 
131
                              &env->vfp.standard_fp_status);
 
132
    tlb_flush(env, 1);
 
133
    /* Reset is a state change for some CPUARMState fields which we
 
134
     * bake assumptions about into translated code, so we need to
 
135
     * tb_flush().
 
136
     */
 
137
    tb_flush(env);
 
138
}
 
139
 
 
140
#ifndef CONFIG_USER_ONLY
 
141
static void arm_cpu_set_irq(void *opaque, int irq, int level)
 
142
{
 
143
    ARMCPU *cpu = opaque;
 
144
    CPUState *cs = CPU(cpu);
 
145
 
 
146
    switch (irq) {
 
147
    case ARM_CPU_IRQ:
 
148
        if (level) {
 
149
            cpu_interrupt(cs, CPU_INTERRUPT_HARD);
 
150
        } else {
 
151
            cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
 
152
        }
 
153
        break;
 
154
    case ARM_CPU_FIQ:
 
155
        if (level) {
 
156
            cpu_interrupt(cs, CPU_INTERRUPT_FIQ);
 
157
        } else {
 
158
            cpu_reset_interrupt(cs, CPU_INTERRUPT_FIQ);
 
159
        }
 
160
        break;
 
161
    default:
 
162
        hw_error("arm_cpu_set_irq: Bad interrupt line %d\n", irq);
 
163
    }
 
164
}
 
165
 
 
166
static void arm_cpu_kvm_set_irq(void *opaque, int irq, int level)
 
167
{
 
168
#ifdef CONFIG_KVM
 
169
    ARMCPU *cpu = opaque;
 
170
    CPUState *cs = CPU(cpu);
 
171
    int kvm_irq = KVM_ARM_IRQ_TYPE_CPU << KVM_ARM_IRQ_TYPE_SHIFT;
 
172
 
 
173
    switch (irq) {
 
174
    case ARM_CPU_IRQ:
 
175
        kvm_irq |= KVM_ARM_IRQ_CPU_IRQ;
 
176
        break;
 
177
    case ARM_CPU_FIQ:
 
178
        kvm_irq |= KVM_ARM_IRQ_CPU_FIQ;
 
179
        break;
 
180
    default:
 
181
        hw_error("arm_cpu_kvm_set_irq: Bad interrupt line %d\n", irq);
 
182
    }
 
183
    kvm_irq |= cs->cpu_index << KVM_ARM_IRQ_VCPU_SHIFT;
 
184
    kvm_set_irq(kvm_state, kvm_irq, level ? 1 : 0);
 
185
#endif
 
186
}
 
187
#endif
 
188
 
 
189
static inline void set_feature(CPUARMState *env, int feature)
 
190
{
 
191
    env->features |= 1ULL << feature;
 
192
}
 
193
 
 
194
static void arm_cpu_initfn(Object *obj)
 
195
{
 
196
    CPUState *cs = CPU(obj);
 
197
    ARMCPU *cpu = ARM_CPU(obj);
 
198
    static bool inited;
 
199
 
 
200
    cs->env_ptr = &cpu->env;
 
201
    cpu_exec_init(&cpu->env);
 
202
    cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal,
 
203
                                         g_free, g_free);
 
204
 
 
205
#ifndef CONFIG_USER_ONLY
 
206
    /* Our inbound IRQ and FIQ lines */
 
207
    if (kvm_enabled()) {
 
208
        qdev_init_gpio_in(DEVICE(cpu), arm_cpu_kvm_set_irq, 2);
 
209
    } else {
 
210
        qdev_init_gpio_in(DEVICE(cpu), arm_cpu_set_irq, 2);
 
211
    }
 
212
 
 
213
    cpu->gt_timer[GTIMER_PHYS] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE,
 
214
                                                arm_gt_ptimer_cb, cpu);
 
215
    cpu->gt_timer[GTIMER_VIRT] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE,
 
216
                                                arm_gt_vtimer_cb, cpu);
 
217
    qdev_init_gpio_out(DEVICE(cpu), cpu->gt_timer_outputs,
 
218
                       ARRAY_SIZE(cpu->gt_timer_outputs));
 
219
#endif
 
220
 
 
221
    /* DTB consumers generally don't in fact care what the 'compatible'
 
222
     * string is, so always provide some string and trust that a hypothetical
 
223
     * picky DTB consumer will also provide a helpful error message.
 
224
     */
 
225
    cpu->dtb_compatible = "qemu,unknown";
 
226
 
 
227
    if (tcg_enabled() && !inited) {
 
228
        inited = true;
 
229
        arm_translate_init();
 
230
    }
 
231
}
 
232
 
 
233
static void arm_cpu_finalizefn(Object *obj)
 
234
{
 
235
    ARMCPU *cpu = ARM_CPU(obj);
 
236
    g_hash_table_destroy(cpu->cp_regs);
 
237
}
 
238
 
 
239
static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
 
240
{
 
241
    CPUState *cs = CPU(dev);
 
242
    ARMCPU *cpu = ARM_CPU(dev);
 
243
    ARMCPUClass *acc = ARM_CPU_GET_CLASS(dev);
 
244
    CPUARMState *env = &cpu->env;
 
245
 
 
246
    /* Some features automatically imply others: */
 
247
    if (arm_feature(env, ARM_FEATURE_V8)) {
 
248
        set_feature(env, ARM_FEATURE_V7);
 
249
        set_feature(env, ARM_FEATURE_ARM_DIV);
 
250
        set_feature(env, ARM_FEATURE_LPAE);
 
251
    }
 
252
    if (arm_feature(env, ARM_FEATURE_V7)) {
 
253
        set_feature(env, ARM_FEATURE_VAPA);
 
254
        set_feature(env, ARM_FEATURE_THUMB2);
 
255
        set_feature(env, ARM_FEATURE_MPIDR);
 
256
        if (!arm_feature(env, ARM_FEATURE_M)) {
 
257
            set_feature(env, ARM_FEATURE_V6K);
 
258
        } else {
 
259
            set_feature(env, ARM_FEATURE_V6);
 
260
        }
 
261
    }
 
262
    if (arm_feature(env, ARM_FEATURE_V6K)) {
 
263
        set_feature(env, ARM_FEATURE_V6);
 
264
        set_feature(env, ARM_FEATURE_MVFR);
 
265
    }
 
266
    if (arm_feature(env, ARM_FEATURE_V6)) {
 
267
        set_feature(env, ARM_FEATURE_V5);
 
268
        if (!arm_feature(env, ARM_FEATURE_M)) {
 
269
            set_feature(env, ARM_FEATURE_AUXCR);
 
270
        }
 
271
    }
 
272
    if (arm_feature(env, ARM_FEATURE_V5)) {
 
273
        set_feature(env, ARM_FEATURE_V4T);
 
274
    }
 
275
    if (arm_feature(env, ARM_FEATURE_M)) {
 
276
        set_feature(env, ARM_FEATURE_THUMB_DIV);
 
277
    }
 
278
    if (arm_feature(env, ARM_FEATURE_ARM_DIV)) {
 
279
        set_feature(env, ARM_FEATURE_THUMB_DIV);
 
280
    }
 
281
    if (arm_feature(env, ARM_FEATURE_VFP4)) {
 
282
        set_feature(env, ARM_FEATURE_VFP3);
 
283
    }
 
284
    if (arm_feature(env, ARM_FEATURE_VFP3)) {
 
285
        set_feature(env, ARM_FEATURE_VFP);
 
286
    }
 
287
    if (arm_feature(env, ARM_FEATURE_LPAE)) {
 
288
        set_feature(env, ARM_FEATURE_V7MP);
 
289
        set_feature(env, ARM_FEATURE_PXN);
 
290
    }
 
291
 
 
292
    register_cp_regs_for_features(cpu);
 
293
    arm_cpu_register_gdb_regs_for_features(cpu);
 
294
 
 
295
    init_cpreg_list(cpu);
 
296
 
 
297
    cpu_reset(cs);
 
298
    qemu_init_vcpu(cs);
 
299
 
 
300
    acc->parent_realize(dev, errp);
 
301
}
 
302
 
 
303
static ObjectClass *arm_cpu_class_by_name(const char *cpu_model)
 
304
{
 
305
    ObjectClass *oc;
 
306
    char *typename;
 
307
 
 
308
    if (!cpu_model) {
 
309
        return NULL;
 
310
    }
 
311
 
 
312
    typename = g_strdup_printf("%s-" TYPE_ARM_CPU, cpu_model);
 
313
    oc = object_class_by_name(typename);
 
314
    g_free(typename);
 
315
    if (!oc || !object_class_dynamic_cast(oc, TYPE_ARM_CPU) ||
 
316
        object_class_is_abstract(oc)) {
 
317
        return NULL;
 
318
    }
 
319
    return oc;
 
320
}
 
321
 
 
322
/* CPU models. These are not needed for the AArch64 linux-user build. */
 
323
#if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
 
324
 
 
325
static void arm926_initfn(Object *obj)
 
326
{
 
327
    ARMCPU *cpu = ARM_CPU(obj);
 
328
 
 
329
    cpu->dtb_compatible = "arm,arm926";
 
330
    set_feature(&cpu->env, ARM_FEATURE_V5);
 
331
    set_feature(&cpu->env, ARM_FEATURE_VFP);
 
332
    set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
 
333
    set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN);
 
334
    cpu->midr = 0x41069265;
 
335
    cpu->reset_fpsid = 0x41011090;
 
336
    cpu->ctr = 0x1dd20d2;
 
337
    cpu->reset_sctlr = 0x00090078;
 
338
}
 
339
 
 
340
static void arm946_initfn(Object *obj)
 
341
{
 
342
    ARMCPU *cpu = ARM_CPU(obj);
 
343
 
 
344
    cpu->dtb_compatible = "arm,arm946";
 
345
    set_feature(&cpu->env, ARM_FEATURE_V5);
 
346
    set_feature(&cpu->env, ARM_FEATURE_MPU);
 
347
    set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
 
348
    cpu->midr = 0x41059461;
 
349
    cpu->ctr = 0x0f004006;
 
350
    cpu->reset_sctlr = 0x00000078;
 
351
}
 
352
 
 
353
static void arm1026_initfn(Object *obj)
 
354
{
 
355
    ARMCPU *cpu = ARM_CPU(obj);
 
356
 
 
357
    cpu->dtb_compatible = "arm,arm1026";
 
358
    set_feature(&cpu->env, ARM_FEATURE_V5);
 
359
    set_feature(&cpu->env, ARM_FEATURE_VFP);
 
360
    set_feature(&cpu->env, ARM_FEATURE_AUXCR);
 
361
    set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
 
362
    set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN);
 
363
    cpu->midr = 0x4106a262;
 
364
    cpu->reset_fpsid = 0x410110a0;
 
365
    cpu->ctr = 0x1dd20d2;
 
366
    cpu->reset_sctlr = 0x00090078;
 
367
    cpu->reset_auxcr = 1;
 
368
    {
 
369
        /* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */
 
370
        ARMCPRegInfo ifar = {
 
371
            .name = "IFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 1,
 
372
            .access = PL1_RW,
 
373
            .fieldoffset = offsetof(CPUARMState, cp15.c6_insn),
 
374
            .resetvalue = 0
 
375
        };
 
376
        define_one_arm_cp_reg(cpu, &ifar);
 
377
    }
 
378
}
 
379
 
 
380
static void arm1136_r2_initfn(Object *obj)
 
381
{
 
382
    ARMCPU *cpu = ARM_CPU(obj);
 
383
    /* What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an
 
384
     * older core than plain "arm1136". In particular this does not
 
385
     * have the v6K features.
 
386
     * These ID register values are correct for 1136 but may be wrong
 
387
     * for 1136_r2 (in particular r0p2 does not actually implement most
 
388
     * of the ID registers).
 
389
     */
 
390
 
 
391
    cpu->dtb_compatible = "arm,arm1136";
 
392
    set_feature(&cpu->env, ARM_FEATURE_V6);
 
393
    set_feature(&cpu->env, ARM_FEATURE_VFP);
 
394
    set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
 
395
    set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG);
 
396
    set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS);
 
397
    cpu->midr = 0x4107b362;
 
398
    cpu->reset_fpsid = 0x410120b4;
 
399
    cpu->mvfr0 = 0x11111111;
 
400
    cpu->mvfr1 = 0x00000000;
 
401
    cpu->ctr = 0x1dd20d2;
 
402
    cpu->reset_sctlr = 0x00050078;
 
403
    cpu->id_pfr0 = 0x111;
 
404
    cpu->id_pfr1 = 0x1;
 
405
    cpu->id_dfr0 = 0x2;
 
406
    cpu->id_afr0 = 0x3;
 
407
    cpu->id_mmfr0 = 0x01130003;
 
408
    cpu->id_mmfr1 = 0x10030302;
 
409
    cpu->id_mmfr2 = 0x01222110;
 
410
    cpu->id_isar0 = 0x00140011;
 
411
    cpu->id_isar1 = 0x12002111;
 
412
    cpu->id_isar2 = 0x11231111;
 
413
    cpu->id_isar3 = 0x01102131;
 
414
    cpu->id_isar4 = 0x141;
 
415
    cpu->reset_auxcr = 7;
 
416
}
 
417
 
 
418
static void arm1136_initfn(Object *obj)
 
419
{
 
420
    ARMCPU *cpu = ARM_CPU(obj);
 
421
 
 
422
    cpu->dtb_compatible = "arm,arm1136";
 
423
    set_feature(&cpu->env, ARM_FEATURE_V6K);
 
424
    set_feature(&cpu->env, ARM_FEATURE_V6);
 
425
    set_feature(&cpu->env, ARM_FEATURE_VFP);
 
426
    set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
 
427
    set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG);
 
428
    set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS);
 
429
    cpu->midr = 0x4117b363;
 
430
    cpu->reset_fpsid = 0x410120b4;
 
431
    cpu->mvfr0 = 0x11111111;
 
432
    cpu->mvfr1 = 0x00000000;
 
433
    cpu->ctr = 0x1dd20d2;
 
434
    cpu->reset_sctlr = 0x00050078;
 
435
    cpu->id_pfr0 = 0x111;
 
436
    cpu->id_pfr1 = 0x1;
 
437
    cpu->id_dfr0 = 0x2;
 
438
    cpu->id_afr0 = 0x3;
 
439
    cpu->id_mmfr0 = 0x01130003;
 
440
    cpu->id_mmfr1 = 0x10030302;
 
441
    cpu->id_mmfr2 = 0x01222110;
 
442
    cpu->id_isar0 = 0x00140011;
 
443
    cpu->id_isar1 = 0x12002111;
 
444
    cpu->id_isar2 = 0x11231111;
 
445
    cpu->id_isar3 = 0x01102131;
 
446
    cpu->id_isar4 = 0x141;
 
447
    cpu->reset_auxcr = 7;
 
448
}
 
449
 
 
450
static void arm1176_initfn(Object *obj)
 
451
{
 
452
    ARMCPU *cpu = ARM_CPU(obj);
 
453
 
 
454
    cpu->dtb_compatible = "arm,arm1176";
 
455
    set_feature(&cpu->env, ARM_FEATURE_V6K);
 
456
    set_feature(&cpu->env, ARM_FEATURE_VFP);
 
457
    set_feature(&cpu->env, ARM_FEATURE_VAPA);
 
458
    set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
 
459
    set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG);
 
460
    set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS);
 
461
    set_feature(&cpu->env, ARM_FEATURE_TRUSTZONE);
 
462
    cpu->midr = 0x410fb767;
 
463
    cpu->reset_fpsid = 0x410120b5;
 
464
    cpu->mvfr0 = 0x11111111;
 
465
    cpu->mvfr1 = 0x00000000;
 
466
    cpu->ctr = 0x1dd20d2;
 
467
    cpu->reset_sctlr = 0x00050078;
 
468
    cpu->id_pfr0 = 0x111;
 
469
    cpu->id_pfr1 = 0x11;
 
470
    cpu->id_dfr0 = 0x33;
 
471
    cpu->id_afr0 = 0;
 
472
    cpu->id_mmfr0 = 0x01130003;
 
473
    cpu->id_mmfr1 = 0x10030302;
 
474
    cpu->id_mmfr2 = 0x01222100;
 
475
    cpu->id_isar0 = 0x0140011;
 
476
    cpu->id_isar1 = 0x12002111;
 
477
    cpu->id_isar2 = 0x11231121;
 
478
    cpu->id_isar3 = 0x01102131;
 
479
    cpu->id_isar4 = 0x01141;
 
480
    cpu->reset_auxcr = 7;
 
481
}
 
482
 
 
483
static void arm11mpcore_initfn(Object *obj)
 
484
{
 
485
    ARMCPU *cpu = ARM_CPU(obj);
 
486
 
 
487
    cpu->dtb_compatible = "arm,arm11mpcore";
 
488
    set_feature(&cpu->env, ARM_FEATURE_V6K);
 
489
    set_feature(&cpu->env, ARM_FEATURE_VFP);
 
490
    set_feature(&cpu->env, ARM_FEATURE_VAPA);
 
491
    set_feature(&cpu->env, ARM_FEATURE_MPIDR);
 
492
    set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
 
493
    cpu->midr = 0x410fb022;
 
494
    cpu->reset_fpsid = 0x410120b4;
 
495
    cpu->mvfr0 = 0x11111111;
 
496
    cpu->mvfr1 = 0x00000000;
 
497
    cpu->ctr = 0x1d192992; /* 32K icache 32K dcache */
 
498
    cpu->id_pfr0 = 0x111;
 
499
    cpu->id_pfr1 = 0x1;
 
500
    cpu->id_dfr0 = 0;
 
501
    cpu->id_afr0 = 0x2;
 
502
    cpu->id_mmfr0 = 0x01100103;
 
503
    cpu->id_mmfr1 = 0x10020302;
 
504
    cpu->id_mmfr2 = 0x01222000;
 
505
    cpu->id_isar0 = 0x00100011;
 
506
    cpu->id_isar1 = 0x12002111;
 
507
    cpu->id_isar2 = 0x11221011;
 
508
    cpu->id_isar3 = 0x01102131;
 
509
    cpu->id_isar4 = 0x141;
 
510
    cpu->reset_auxcr = 1;
 
511
}
 
512
 
 
513
static void cortex_m3_initfn(Object *obj)
 
514
{
 
515
    ARMCPU *cpu = ARM_CPU(obj);
 
516
    set_feature(&cpu->env, ARM_FEATURE_V7);
 
517
    set_feature(&cpu->env, ARM_FEATURE_M);
 
518
    cpu->midr = 0x410fc231;
 
519
}
 
520
 
 
521
static void arm_v7m_class_init(ObjectClass *oc, void *data)
 
522
{
 
523
#ifndef CONFIG_USER_ONLY
 
524
    CPUClass *cc = CPU_CLASS(oc);
 
525
 
 
526
    cc->do_interrupt = arm_v7m_cpu_do_interrupt;
 
527
#endif
 
528
}
 
529
 
 
530
static const ARMCPRegInfo cortexa8_cp_reginfo[] = {
 
531
    { .name = "L2LOCKDOWN", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 0,
 
532
      .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
 
533
    { .name = "L2AUXCR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2,
 
534
      .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
 
535
    REGINFO_SENTINEL
 
536
};
 
537
 
 
538
static void cortex_a8_initfn(Object *obj)
 
539
{
 
540
    ARMCPU *cpu = ARM_CPU(obj);
 
541
 
 
542
    cpu->dtb_compatible = "arm,cortex-a8";
 
543
    set_feature(&cpu->env, ARM_FEATURE_V7);
 
544
    set_feature(&cpu->env, ARM_FEATURE_VFP3);
 
545
    set_feature(&cpu->env, ARM_FEATURE_NEON);
 
546
    set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
 
547
    set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
 
548
    set_feature(&cpu->env, ARM_FEATURE_TRUSTZONE);
 
549
    cpu->midr = 0x410fc080;
 
550
    cpu->reset_fpsid = 0x410330c0;
 
551
    cpu->mvfr0 = 0x11110222;
 
552
    cpu->mvfr1 = 0x00011100;
 
553
    cpu->ctr = 0x82048004;
 
554
    cpu->reset_sctlr = 0x00c50078;
 
555
    cpu->id_pfr0 = 0x1031;
 
556
    cpu->id_pfr1 = 0x11;
 
557
    cpu->id_dfr0 = 0x400;
 
558
    cpu->id_afr0 = 0;
 
559
    cpu->id_mmfr0 = 0x31100003;
 
560
    cpu->id_mmfr1 = 0x20000000;
 
561
    cpu->id_mmfr2 = 0x01202000;
 
562
    cpu->id_mmfr3 = 0x11;
 
563
    cpu->id_isar0 = 0x00101111;
 
564
    cpu->id_isar1 = 0x12112111;
 
565
    cpu->id_isar2 = 0x21232031;
 
566
    cpu->id_isar3 = 0x11112131;
 
567
    cpu->id_isar4 = 0x00111142;
 
568
    cpu->clidr = (1 << 27) | (2 << 24) | 3;
 
569
    cpu->ccsidr[0] = 0xe007e01a; /* 16k L1 dcache. */
 
570
    cpu->ccsidr[1] = 0x2007e01a; /* 16k L1 icache. */
 
571
    cpu->ccsidr[2] = 0xf0000000; /* No L2 icache. */
 
572
    cpu->reset_auxcr = 2;
 
573
    define_arm_cp_regs(cpu, cortexa8_cp_reginfo);
 
574
}
 
575
 
 
576
static void cortex_a8_r2_initfn(Object *obj)
 
577
{
 
578
    /* TODO:
 
579
     * 1. do we really need this?
 
580
     * 2. are these register values all correct? mostly same as A8 currently
 
581
     */
 
582
    ARMCPU *cpu = ARM_CPU(obj);
 
583
    set_feature(&cpu->env, ARM_FEATURE_V7);
 
584
    set_feature(&cpu->env, ARM_FEATURE_VFP3);
 
585
    set_feature(&cpu->env, ARM_FEATURE_NEON);
 
586
    set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
 
587
    set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
 
588
    set_feature(&cpu->env, ARM_FEATURE_TRUSTZONE);
 
589
    cpu->midr = 0x410fc083;
 
590
    cpu->reset_fpsid = 0x410330c2;
 
591
    cpu->mvfr0 = 0x11110222;
 
592
    cpu->mvfr1 = 0x00011111;
 
593
    cpu->ctr = 0x82048004;
 
594
    cpu->reset_sctlr = 0x00c50078;
 
595
    cpu->id_pfr0 = 0x1031;
 
596
    cpu->id_pfr1 = 0x11;
 
597
    cpu->id_dfr0 = 0x400;
 
598
    cpu->id_afr0 = 0;
 
599
    cpu->id_mmfr0 = 0x31100003;
 
600
    cpu->id_mmfr1 = 0x20000000;
 
601
    cpu->id_mmfr2 = 0x01202000;
 
602
    cpu->id_mmfr3 = 0x11;
 
603
    cpu->id_isar0 = 0x00101111;
 
604
    cpu->id_isar1 = 0x12112111;
 
605
    cpu->id_isar2 = 0x21232031;
 
606
    cpu->id_isar3 = 0x11112131;
 
607
    cpu->id_isar4 = 0x00111142;
 
608
    cpu->clidr = (1 << 27) | (2 << 24) | 3;
 
609
    cpu->ccsidr[0] = 0xe007e01a; /* 16k L1 dcache. */
 
610
    cpu->ccsidr[1] = 0x2007e01a; /* 16k L1 icache. */
 
611
    cpu->ccsidr[2] = 0xf03fe03a; /* 256k L2 cache. */
 
612
    cpu->reset_auxcr = 2;
 
613
    define_arm_cp_regs(cpu, cortexa8_cp_reginfo);
 
614
}
 
615
 
 
616
static const ARMCPRegInfo cortexa9_cp_reginfo[] = {
 
617
    /* power_control should be set to maximum latency. Again,
 
618
     * default to 0 and set by private hook
 
619
     */
 
620
    { .name = "A9_PWRCTL", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 0,
 
621
      .access = PL1_RW, .resetvalue = 0,
 
622
      .fieldoffset = offsetof(CPUARMState, cp15.c15_power_control) },
 
623
    { .name = "A9_DIAG", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 1,
 
624
      .access = PL1_RW, .resetvalue = 0,
 
625
      .fieldoffset = offsetof(CPUARMState, cp15.c15_diagnostic) },
 
626
    { .name = "A9_PWRDIAG", .cp = 15, .crn = 15, .crm = 0, .opc1 = 0, .opc2 = 2,
 
627
      .access = PL1_RW, .resetvalue = 0,
 
628
      .fieldoffset = offsetof(CPUARMState, cp15.c15_power_diagnostic) },
 
629
    { .name = "NEONBUSY", .cp = 15, .crn = 15, .crm = 1, .opc1 = 0, .opc2 = 0,
 
630
      .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
 
631
    /* TLB lockdown control */
 
632
    { .name = "TLB_LOCKR", .cp = 15, .crn = 15, .crm = 4, .opc1 = 5, .opc2 = 2,
 
633
      .access = PL1_W, .resetvalue = 0, .type = ARM_CP_NOP },
 
634
    { .name = "TLB_LOCKW", .cp = 15, .crn = 15, .crm = 4, .opc1 = 5, .opc2 = 4,
 
635
      .access = PL1_W, .resetvalue = 0, .type = ARM_CP_NOP },
 
636
    { .name = "TLB_VA", .cp = 15, .crn = 15, .crm = 5, .opc1 = 5, .opc2 = 2,
 
637
      .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
 
638
    { .name = "TLB_PA", .cp = 15, .crn = 15, .crm = 6, .opc1 = 5, .opc2 = 2,
 
639
      .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
 
640
    { .name = "TLB_ATTR", .cp = 15, .crn = 15, .crm = 7, .opc1 = 5, .opc2 = 2,
 
641
      .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
 
642
    REGINFO_SENTINEL
 
643
};
 
644
 
 
645
static void cortex_a9_initfn(Object *obj)
 
646
{
 
647
    ARMCPU *cpu = ARM_CPU(obj);
 
648
 
 
649
    cpu->dtb_compatible = "arm,cortex-a9";
 
650
    set_feature(&cpu->env, ARM_FEATURE_V7);
 
651
    set_feature(&cpu->env, ARM_FEATURE_VFP3);
 
652
    set_feature(&cpu->env, ARM_FEATURE_VFP_FP16);
 
653
    set_feature(&cpu->env, ARM_FEATURE_NEON);
 
654
    set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
 
655
    /* Note that A9 supports the MP extensions even for
 
656
     * A9UP and single-core A9MP (which are both different
 
657
     * and valid configurations; we don't model A9UP).
 
658
     */
 
659
    set_feature(&cpu->env, ARM_FEATURE_V7MP);
 
660
    set_feature(&cpu->env, ARM_FEATURE_TRUSTZONE);
 
661
    cpu->midr = 0x410fc090;
 
662
    cpu->reset_fpsid = 0x41033090;
 
663
    cpu->mvfr0 = 0x11110222;
 
664
    cpu->mvfr1 = 0x01111111;
 
665
    cpu->ctr = 0x80038003;
 
666
    cpu->reset_sctlr = 0x00c50078;
 
667
    cpu->id_pfr0 = 0x1031;
 
668
    cpu->id_pfr1 = 0x11;
 
669
    cpu->id_dfr0 = 0x000;
 
670
    cpu->id_afr0 = 0;
 
671
    cpu->id_mmfr0 = 0x00100103;
 
672
    cpu->id_mmfr1 = 0x20000000;
 
673
    cpu->id_mmfr2 = 0x01230000;
 
674
    cpu->id_mmfr3 = 0x00002111;
 
675
    cpu->id_isar0 = 0x00101111;
 
676
    cpu->id_isar1 = 0x13112111;
 
677
    cpu->id_isar2 = 0x21232041;
 
678
    cpu->id_isar3 = 0x11112131;
 
679
    cpu->id_isar4 = 0x00111142;
 
680
    cpu->clidr = (1 << 27) | (1 << 24) | 3;
 
681
    cpu->ccsidr[0] = 0xe00fe015; /* 16k L1 dcache. */
 
682
    cpu->ccsidr[1] = 0x200fe015; /* 16k L1 icache. */
 
683
    {
 
684
        ARMCPRegInfo cbar = {
 
685
            .name = "CBAR", .cp = 15, .crn = 15,  .crm = 0, .opc1 = 4,
 
686
            .opc2 = 0, .access = PL1_R|PL3_W, .resetvalue = cpu->reset_cbar,
 
687
            .fieldoffset = offsetof(CPUARMState, cp15.c15_config_base_address)
 
688
        };
 
689
        define_one_arm_cp_reg(cpu, &cbar);
 
690
        define_arm_cp_regs(cpu, cortexa9_cp_reginfo);
 
691
    }
 
692
}
 
693
 
 
694
#ifndef CONFIG_USER_ONLY
 
695
static int a15_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri,
 
696
                           uint64_t *value)
 
697
{
 
698
    /* Linux wants the number of processors from here.
 
699
     * Might as well set the interrupt-controller bit too.
 
700
     */
 
701
    *value = ((smp_cpus - 1) << 24) | (1 << 23);
 
702
    return 0;
 
703
}
 
704
#endif
 
705
 
 
706
static const ARMCPRegInfo cortexa15_cp_reginfo[] = {
 
707
#ifndef CONFIG_USER_ONLY
 
708
    { .name = "L2CTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2,
 
709
      .access = PL1_RW, .resetvalue = 0, .readfn = a15_l2ctlr_read,
 
710
      .writefn = arm_cp_write_ignore, },
 
711
#endif
 
712
    { .name = "L2ECTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 3,
 
713
      .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
 
714
    REGINFO_SENTINEL
 
715
};
 
716
 
 
717
static void cortex_a15_initfn(Object *obj)
 
718
{
 
719
    ARMCPU *cpu = ARM_CPU(obj);
 
720
 
 
721
    cpu->dtb_compatible = "arm,cortex-a15";
 
722
    set_feature(&cpu->env, ARM_FEATURE_V7);
 
723
    set_feature(&cpu->env, ARM_FEATURE_VFP4);
 
724
    set_feature(&cpu->env, ARM_FEATURE_VFP_FP16);
 
725
    set_feature(&cpu->env, ARM_FEATURE_NEON);
 
726
    set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
 
727
    set_feature(&cpu->env, ARM_FEATURE_ARM_DIV);
 
728
    set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
 
729
    set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
 
730
    set_feature(&cpu->env, ARM_FEATURE_LPAE);
 
731
    set_feature(&cpu->env, ARM_FEATURE_TRUSTZONE);
 
732
    cpu->midr = 0x412fc0f1;
 
733
    cpu->reset_fpsid = 0x410430f0;
 
734
    cpu->mvfr0 = 0x10110222;
 
735
    cpu->mvfr1 = 0x11111111;
 
736
    cpu->ctr = 0x8444c004;
 
737
    cpu->reset_sctlr = 0x00c50078;
 
738
    cpu->id_pfr0 = 0x00001131;
 
739
    cpu->id_pfr1 = 0x00011011;
 
740
    cpu->id_dfr0 = 0x02010555;
 
741
    cpu->id_afr0 = 0x00000000;
 
742
    cpu->id_mmfr0 = 0x10201105;
 
743
    cpu->id_mmfr1 = 0x20000000;
 
744
    cpu->id_mmfr2 = 0x01240000;
 
745
    cpu->id_mmfr3 = 0x02102211;
 
746
    cpu->id_isar0 = 0x02101110;
 
747
    cpu->id_isar1 = 0x13112111;
 
748
    cpu->id_isar2 = 0x21232041;
 
749
    cpu->id_isar3 = 0x11112131;
 
750
    cpu->id_isar4 = 0x10011142;
 
751
    cpu->clidr = 0x0a200023;
 
752
    cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */
 
753
    cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */
 
754
    cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */
 
755
    define_arm_cp_regs(cpu, cortexa15_cp_reginfo);
 
756
}
 
757
 
 
758
static void ti925t_initfn(Object *obj)
 
759
{
 
760
    ARMCPU *cpu = ARM_CPU(obj);
 
761
    set_feature(&cpu->env, ARM_FEATURE_V4T);
 
762
    set_feature(&cpu->env, ARM_FEATURE_OMAPCP);
 
763
    cpu->midr = ARM_CPUID_TI925T;
 
764
    cpu->ctr = 0x5109149;
 
765
    cpu->reset_sctlr = 0x00000070;
 
766
}
 
767
 
 
768
static void sa1100_initfn(Object *obj)
 
769
{
 
770
    ARMCPU *cpu = ARM_CPU(obj);
 
771
 
 
772
    cpu->dtb_compatible = "intel,sa1100";
 
773
    set_feature(&cpu->env, ARM_FEATURE_STRONGARM);
 
774
    set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
 
775
    cpu->midr = 0x4401A11B;
 
776
    cpu->reset_sctlr = 0x00000070;
 
777
}
 
778
 
 
779
static void sa1110_initfn(Object *obj)
 
780
{
 
781
    ARMCPU *cpu = ARM_CPU(obj);
 
782
    set_feature(&cpu->env, ARM_FEATURE_STRONGARM);
 
783
    set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
 
784
    cpu->midr = 0x6901B119;
 
785
    cpu->reset_sctlr = 0x00000070;
 
786
}
 
787
 
 
788
static void pxa250_initfn(Object *obj)
 
789
{
 
790
    ARMCPU *cpu = ARM_CPU(obj);
 
791
 
 
792
    cpu->dtb_compatible = "marvell,xscale";
 
793
    set_feature(&cpu->env, ARM_FEATURE_V5);
 
794
    set_feature(&cpu->env, ARM_FEATURE_XSCALE);
 
795
    cpu->midr = 0x69052100;
 
796
    cpu->ctr = 0xd172172;
 
797
    cpu->reset_sctlr = 0x00000078;
 
798
}
 
799
 
 
800
static void pxa255_initfn(Object *obj)
 
801
{
 
802
    ARMCPU *cpu = ARM_CPU(obj);
 
803
 
 
804
    cpu->dtb_compatible = "marvell,xscale";
 
805
    set_feature(&cpu->env, ARM_FEATURE_V5);
 
806
    set_feature(&cpu->env, ARM_FEATURE_XSCALE);
 
807
    cpu->midr = 0x69052d00;
 
808
    cpu->ctr = 0xd172172;
 
809
    cpu->reset_sctlr = 0x00000078;
 
810
}
 
811
 
 
812
static void pxa260_initfn(Object *obj)
 
813
{
 
814
    ARMCPU *cpu = ARM_CPU(obj);
 
815
 
 
816
    cpu->dtb_compatible = "marvell,xscale";
 
817
    set_feature(&cpu->env, ARM_FEATURE_V5);
 
818
    set_feature(&cpu->env, ARM_FEATURE_XSCALE);
 
819
    cpu->midr = 0x69052903;
 
820
    cpu->ctr = 0xd172172;
 
821
    cpu->reset_sctlr = 0x00000078;
 
822
}
 
823
 
 
824
static void pxa261_initfn(Object *obj)
 
825
{
 
826
    ARMCPU *cpu = ARM_CPU(obj);
 
827
 
 
828
    cpu->dtb_compatible = "marvell,xscale";
 
829
    set_feature(&cpu->env, ARM_FEATURE_V5);
 
830
    set_feature(&cpu->env, ARM_FEATURE_XSCALE);
 
831
    cpu->midr = 0x69052d05;
 
832
    cpu->ctr = 0xd172172;
 
833
    cpu->reset_sctlr = 0x00000078;
 
834
}
 
835
 
 
836
static void pxa262_initfn(Object *obj)
 
837
{
 
838
    ARMCPU *cpu = ARM_CPU(obj);
 
839
 
 
840
    cpu->dtb_compatible = "marvell,xscale";
 
841
    set_feature(&cpu->env, ARM_FEATURE_V5);
 
842
    set_feature(&cpu->env, ARM_FEATURE_XSCALE);
 
843
    cpu->midr = 0x69052d06;
 
844
    cpu->ctr = 0xd172172;
 
845
    cpu->reset_sctlr = 0x00000078;
 
846
}
 
847
 
 
848
static void pxa270a0_initfn(Object *obj)
 
849
{
 
850
    ARMCPU *cpu = ARM_CPU(obj);
 
851
 
 
852
    cpu->dtb_compatible = "marvell,xscale";
 
853
    set_feature(&cpu->env, ARM_FEATURE_V5);
 
854
    set_feature(&cpu->env, ARM_FEATURE_XSCALE);
 
855
    set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
 
856
    cpu->midr = 0x69054110;
 
857
    cpu->ctr = 0xd172172;
 
858
    cpu->reset_sctlr = 0x00000078;
 
859
}
 
860
 
 
861
static void pxa270a1_initfn(Object *obj)
 
862
{
 
863
    ARMCPU *cpu = ARM_CPU(obj);
 
864
 
 
865
    cpu->dtb_compatible = "marvell,xscale";
 
866
    set_feature(&cpu->env, ARM_FEATURE_V5);
 
867
    set_feature(&cpu->env, ARM_FEATURE_XSCALE);
 
868
    set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
 
869
    cpu->midr = 0x69054111;
 
870
    cpu->ctr = 0xd172172;
 
871
    cpu->reset_sctlr = 0x00000078;
 
872
}
 
873
 
 
874
static void pxa270b0_initfn(Object *obj)
 
875
{
 
876
    ARMCPU *cpu = ARM_CPU(obj);
 
877
 
 
878
    cpu->dtb_compatible = "marvell,xscale";
 
879
    set_feature(&cpu->env, ARM_FEATURE_V5);
 
880
    set_feature(&cpu->env, ARM_FEATURE_XSCALE);
 
881
    set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
 
882
    cpu->midr = 0x69054112;
 
883
    cpu->ctr = 0xd172172;
 
884
    cpu->reset_sctlr = 0x00000078;
 
885
}
 
886
 
 
887
static void pxa270b1_initfn(Object *obj)
 
888
{
 
889
    ARMCPU *cpu = ARM_CPU(obj);
 
890
 
 
891
    cpu->dtb_compatible = "marvell,xscale";
 
892
    set_feature(&cpu->env, ARM_FEATURE_V5);
 
893
    set_feature(&cpu->env, ARM_FEATURE_XSCALE);
 
894
    set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
 
895
    cpu->midr = 0x69054113;
 
896
    cpu->ctr = 0xd172172;
 
897
    cpu->reset_sctlr = 0x00000078;
 
898
}
 
899
 
 
900
static void pxa270c0_initfn(Object *obj)
 
901
{
 
902
    ARMCPU *cpu = ARM_CPU(obj);
 
903
 
 
904
    cpu->dtb_compatible = "marvell,xscale";
 
905
    set_feature(&cpu->env, ARM_FEATURE_V5);
 
906
    set_feature(&cpu->env, ARM_FEATURE_XSCALE);
 
907
    set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
 
908
    cpu->midr = 0x69054114;
 
909
    cpu->ctr = 0xd172172;
 
910
    cpu->reset_sctlr = 0x00000078;
 
911
}
 
912
 
 
913
static void pxa270c5_initfn(Object *obj)
 
914
{
 
915
    ARMCPU *cpu = ARM_CPU(obj);
 
916
 
 
917
    cpu->dtb_compatible = "marvell,xscale";
 
918
    set_feature(&cpu->env, ARM_FEATURE_V5);
 
919
    set_feature(&cpu->env, ARM_FEATURE_XSCALE);
 
920
    set_feature(&cpu->env, ARM_FEATURE_IWMMXT);
 
921
    cpu->midr = 0x69054117;
 
922
    cpu->ctr = 0xd172172;
 
923
    cpu->reset_sctlr = 0x00000078;
 
924
}
 
925
 
 
926
#ifdef CONFIG_USER_ONLY
 
927
static void arm_any_initfn(Object *obj)
 
928
{
 
929
    ARMCPU *cpu = ARM_CPU(obj);
 
930
    set_feature(&cpu->env, ARM_FEATURE_V8);
 
931
    set_feature(&cpu->env, ARM_FEATURE_VFP4);
 
932
    set_feature(&cpu->env, ARM_FEATURE_VFP_FP16);
 
933
    set_feature(&cpu->env, ARM_FEATURE_NEON);
 
934
    set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
 
935
    set_feature(&cpu->env, ARM_FEATURE_ARM_DIV);
 
936
    set_feature(&cpu->env, ARM_FEATURE_V7MP);
 
937
#ifdef TARGET_AARCH64
 
938
    set_feature(&cpu->env, ARM_FEATURE_AARCH64);
 
939
#endif
 
940
    cpu->midr = 0xffffffff;
 
941
}
 
942
#endif
 
943
 
 
944
#endif /* !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) */
 
945
 
 
946
typedef struct ARMCPUInfo {
 
947
    const char *name;
 
948
    void (*initfn)(Object *obj);
 
949
    void (*class_init)(ObjectClass *oc, void *data);
 
950
} ARMCPUInfo;
 
951
 
 
952
static const ARMCPUInfo arm_cpus[] = {
 
953
#if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
 
954
    { .name = "arm926",      .initfn = arm926_initfn },
 
955
    { .name = "arm946",      .initfn = arm946_initfn },
 
956
    { .name = "arm1026",     .initfn = arm1026_initfn },
 
957
    /* What QEMU calls "arm1136-r2" is actually the 1136 r0p2, i.e. an
 
958
     * older core than plain "arm1136". In particular this does not
 
959
     * have the v6K features.
 
960
     */
 
961
    { .name = "arm1136-r2",  .initfn = arm1136_r2_initfn },
 
962
    { .name = "arm1136",     .initfn = arm1136_initfn },
 
963
    { .name = "arm1176",     .initfn = arm1176_initfn },
 
964
    { .name = "arm11mpcore", .initfn = arm11mpcore_initfn },
 
965
    { .name = "cortex-m3",   .initfn = cortex_m3_initfn,
 
966
                             .class_init = arm_v7m_class_init },
 
967
    { .name = "cortex-a8",   .initfn = cortex_a8_initfn },
 
968
    { .name = "cortex-a8-r2",.initfn = cortex_a8_r2_initfn },
 
969
    { .name = "cortex-a9",   .initfn = cortex_a9_initfn },
 
970
    { .name = "cortex-a15",  .initfn = cortex_a15_initfn },
 
971
    { .name = "ti925t",      .initfn = ti925t_initfn },
 
972
    { .name = "sa1100",      .initfn = sa1100_initfn },
 
973
    { .name = "sa1110",      .initfn = sa1110_initfn },
 
974
    { .name = "pxa250",      .initfn = pxa250_initfn },
 
975
    { .name = "pxa255",      .initfn = pxa255_initfn },
 
976
    { .name = "pxa260",      .initfn = pxa260_initfn },
 
977
    { .name = "pxa261",      .initfn = pxa261_initfn },
 
978
    { .name = "pxa262",      .initfn = pxa262_initfn },
 
979
    /* "pxa270" is an alias for "pxa270-a0" */
 
980
    { .name = "pxa270",      .initfn = pxa270a0_initfn },
 
981
    { .name = "pxa270-a0",   .initfn = pxa270a0_initfn },
 
982
    { .name = "pxa270-a1",   .initfn = pxa270a1_initfn },
 
983
    { .name = "pxa270-b0",   .initfn = pxa270b0_initfn },
 
984
    { .name = "pxa270-b1",   .initfn = pxa270b1_initfn },
 
985
    { .name = "pxa270-c0",   .initfn = pxa270c0_initfn },
 
986
    { .name = "pxa270-c5",   .initfn = pxa270c5_initfn },
 
987
#ifdef CONFIG_USER_ONLY
 
988
    { .name = "any",         .initfn = arm_any_initfn },
 
989
#endif
 
990
#endif
 
991
};
 
992
 
 
993
static Property arm_cpu_properties[] = {
 
994
    DEFINE_PROP_BOOL("start-powered-off", ARMCPU, start_powered_off, false),
 
995
    DEFINE_PROP_END_OF_LIST()
 
996
};
 
997
 
 
998
static void arm_cpu_class_init(ObjectClass *oc, void *data)
 
999
{
 
1000
    ARMCPUClass *acc = ARM_CPU_CLASS(oc);
 
1001
    CPUClass *cc = CPU_CLASS(acc);
 
1002
    DeviceClass *dc = DEVICE_CLASS(oc);
 
1003
 
 
1004
    acc->parent_realize = dc->realize;
 
1005
    dc->realize = arm_cpu_realizefn;
 
1006
    dc->props = arm_cpu_properties;
 
1007
 
 
1008
    acc->parent_reset = cc->reset;
 
1009
    cc->reset = arm_cpu_reset;
 
1010
 
 
1011
    cc->class_by_name = arm_cpu_class_by_name;
 
1012
    cc->do_interrupt = arm_cpu_do_interrupt;
 
1013
    cc->dump_state = arm_cpu_dump_state;
 
1014
    cc->set_pc = arm_cpu_set_pc;
 
1015
    cc->gdb_read_register = arm_cpu_gdb_read_register;
 
1016
    cc->gdb_write_register = arm_cpu_gdb_write_register;
 
1017
#ifndef CONFIG_USER_ONLY
 
1018
    cc->get_phys_page_debug = arm_cpu_get_phys_page_debug;
 
1019
    cc->vmsd = &vmstate_arm_cpu;
 
1020
#endif
 
1021
    cc->gdb_num_core_regs = 26;
 
1022
    cc->gdb_core_xml_file = "arm-core.xml";
 
1023
}
 
1024
 
 
1025
static void cpu_register(const ARMCPUInfo *info)
 
1026
{
 
1027
    TypeInfo type_info = {
 
1028
        .parent = TYPE_ARM_CPU,
 
1029
        .instance_size = sizeof(ARMCPU),
 
1030
        .instance_init = info->initfn,
 
1031
        .class_size = sizeof(ARMCPUClass),
 
1032
        .class_init = info->class_init,
 
1033
    };
 
1034
 
 
1035
    type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);
 
1036
    type_register(&type_info);
 
1037
    g_free((void *)type_info.name);
 
1038
}
 
1039
 
 
1040
static const TypeInfo arm_cpu_type_info = {
 
1041
    .name = TYPE_ARM_CPU,
 
1042
    .parent = TYPE_CPU,
 
1043
    .instance_size = sizeof(ARMCPU),
 
1044
    .instance_init = arm_cpu_initfn,
 
1045
    .instance_finalize = arm_cpu_finalizefn,
 
1046
    .abstract = true,
 
1047
    .class_size = sizeof(ARMCPUClass),
 
1048
    .class_init = arm_cpu_class_init,
 
1049
};
 
1050
 
 
1051
static void arm_cpu_register_types(void)
 
1052
{
 
1053
    int i;
 
1054
 
 
1055
    type_register_static(&arm_cpu_type_info);
 
1056
    for (i = 0; i < ARRAY_SIZE(arm_cpus); i++) {
 
1057
        cpu_register(&arm_cpus[i]);
 
1058
    }
 
1059
}
 
1060
 
 
1061
type_init(arm_cpu_register_types)