]> git.proxmox.com Git - mirror_qemu.git/blame - target-arm/cpu64.c
target-arm: Implement AArch64 EL1 exception handling
[mirror_qemu.git] / target-arm / cpu64.c
CommitLineData
d14d42f1
PM
1/*
2 * QEMU AArch64 CPU
3 *
4 * Copyright (c) 2013 Linaro Ltd
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#if !defined(CONFIG_USER_ONLY)
24#include "hw/loader.h"
25#endif
26#include "hw/arm/arm.h"
27#include "sysemu/sysemu.h"
28#include "sysemu/kvm.h"
29
30static inline void set_feature(CPUARMState *env, int feature)
31{
32 env->features |= 1ULL << feature;
33}
34
35#ifdef CONFIG_USER_ONLY
36static void aarch64_any_initfn(Object *obj)
37{
38 ARMCPU *cpu = ARM_CPU(obj);
39
40 set_feature(&cpu->env, ARM_FEATURE_V8);
41 set_feature(&cpu->env, ARM_FEATURE_VFP4);
42 set_feature(&cpu->env, ARM_FEATURE_VFP_FP16);
43 set_feature(&cpu->env, ARM_FEATURE_NEON);
44 set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
45 set_feature(&cpu->env, ARM_FEATURE_ARM_DIV);
46 set_feature(&cpu->env, ARM_FEATURE_V7MP);
47 set_feature(&cpu->env, ARM_FEATURE_AARCH64);
7da845b0 48 cpu->ctr = 0x80030003; /* 32 byte I and D cacheline size, VIPT icache */
aca3f40b 49 cpu->dcz_blocksize = 7; /* 512 bytes */
d14d42f1
PM
50}
51#endif
52
53typedef struct ARMCPUInfo {
54 const char *name;
55 void (*initfn)(Object *obj);
56 void (*class_init)(ObjectClass *oc, void *data);
57} ARMCPUInfo;
58
59static const ARMCPUInfo aarch64_cpus[] = {
60#ifdef CONFIG_USER_ONLY
61 { .name = "any", .initfn = aarch64_any_initfn },
62#endif
83e6813a 63 { .name = NULL }
d14d42f1
PM
64};
65
66static void aarch64_cpu_initfn(Object *obj)
67{
68}
69
70static void aarch64_cpu_finalizefn(Object *obj)
71{
72}
73
5ce4f357
AG
74static void aarch64_cpu_set_pc(CPUState *cs, vaddr value)
75{
76 ARMCPU *cpu = ARM_CPU(cs);
77 /*
78 * TODO: this will need updating for system emulation,
79 * when the core may be in AArch32 mode.
80 */
81 cpu->env.pc = value;
82}
83
d14d42f1
PM
84static void aarch64_cpu_class_init(ObjectClass *oc, void *data)
85{
14ade10f
AG
86 CPUClass *cc = CPU_CLASS(oc);
87
52e60cdd 88 cc->do_interrupt = aarch64_cpu_do_interrupt;
14ade10f 89 cc->dump_state = aarch64_cpu_dump_state;
5ce4f357 90 cc->set_pc = aarch64_cpu_set_pc;
96c04212
AG
91 cc->gdb_read_register = aarch64_cpu_gdb_read_register;
92 cc->gdb_write_register = aarch64_cpu_gdb_write_register;
93 cc->gdb_num_core_regs = 34;
94 cc->gdb_core_xml_file = "aarch64-core.xml";
d14d42f1
PM
95}
96
97static void aarch64_cpu_register(const ARMCPUInfo *info)
98{
99 TypeInfo type_info = {
100 .parent = TYPE_AARCH64_CPU,
101 .instance_size = sizeof(ARMCPU),
102 .instance_init = info->initfn,
103 .class_size = sizeof(ARMCPUClass),
104 .class_init = info->class_init,
105 };
106
107 type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);
108 type_register(&type_info);
109 g_free((void *)type_info.name);
110}
111
112static const TypeInfo aarch64_cpu_type_info = {
113 .name = TYPE_AARCH64_CPU,
114 .parent = TYPE_ARM_CPU,
115 .instance_size = sizeof(ARMCPU),
116 .instance_init = aarch64_cpu_initfn,
117 .instance_finalize = aarch64_cpu_finalizefn,
118 .abstract = true,
119 .class_size = sizeof(AArch64CPUClass),
120 .class_init = aarch64_cpu_class_init,
121};
122
123static void aarch64_cpu_register_types(void)
124{
83e6813a 125 const ARMCPUInfo *info = aarch64_cpus;
d14d42f1
PM
126
127 type_register_static(&aarch64_cpu_type_info);
83e6813a
PM
128
129 while (info->name) {
130 aarch64_cpu_register(info);
131 info++;
d14d42f1
PM
132 }
133}
134
135type_init(aarch64_cpu_register_types)