]> Git Repo - qemu.git/blob - target-arm/cpu64.c
Merge remote-tracking branch 'qemu-kvm/uq/master' into staging
[qemu.git] / target-arm / cpu64.c
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
30 static inline void set_feature(CPUARMState *env, int feature)
31 {
32     env->features |= 1ULL << feature;
33 }
34
35 #ifdef CONFIG_USER_ONLY
36 static 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);
48 }
49 #endif
50
51 typedef struct ARMCPUInfo {
52     const char *name;
53     void (*initfn)(Object *obj);
54     void (*class_init)(ObjectClass *oc, void *data);
55 } ARMCPUInfo;
56
57 static const ARMCPUInfo aarch64_cpus[] = {
58 #ifdef CONFIG_USER_ONLY
59     { .name = "any",         .initfn = aarch64_any_initfn },
60 #endif
61     { .name = NULL }
62 };
63
64 static void aarch64_cpu_initfn(Object *obj)
65 {
66 }
67
68 static void aarch64_cpu_finalizefn(Object *obj)
69 {
70 }
71
72 static void aarch64_cpu_set_pc(CPUState *cs, vaddr value)
73 {
74     ARMCPU *cpu = ARM_CPU(cs);
75     /*
76      * TODO: this will need updating for system emulation,
77      * when the core may be in AArch32 mode.
78      */
79     cpu->env.pc = value;
80 }
81
82 static void aarch64_cpu_class_init(ObjectClass *oc, void *data)
83 {
84     CPUClass *cc = CPU_CLASS(oc);
85
86     cc->dump_state = aarch64_cpu_dump_state;
87     cc->set_pc = aarch64_cpu_set_pc;
88     cc->gdb_read_register = aarch64_cpu_gdb_read_register;
89     cc->gdb_write_register = aarch64_cpu_gdb_write_register;
90     cc->gdb_num_core_regs = 34;
91     cc->gdb_core_xml_file = "aarch64-core.xml";
92 }
93
94 static void aarch64_cpu_register(const ARMCPUInfo *info)
95 {
96     TypeInfo type_info = {
97         .parent = TYPE_AARCH64_CPU,
98         .instance_size = sizeof(ARMCPU),
99         .instance_init = info->initfn,
100         .class_size = sizeof(ARMCPUClass),
101         .class_init = info->class_init,
102     };
103
104     type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);
105     type_register(&type_info);
106     g_free((void *)type_info.name);
107 }
108
109 static const TypeInfo aarch64_cpu_type_info = {
110     .name = TYPE_AARCH64_CPU,
111     .parent = TYPE_ARM_CPU,
112     .instance_size = sizeof(ARMCPU),
113     .instance_init = aarch64_cpu_initfn,
114     .instance_finalize = aarch64_cpu_finalizefn,
115     .abstract = true,
116     .class_size = sizeof(AArch64CPUClass),
117     .class_init = aarch64_cpu_class_init,
118 };
119
120 static void aarch64_cpu_register_types(void)
121 {
122     const ARMCPUInfo *info = aarch64_cpus;
123
124     type_register_static(&aarch64_cpu_type_info);
125
126     while (info->name) {
127         aarch64_cpu_register(info);
128         info++;
129     }
130 }
131
132 type_init(aarch64_cpu_register_types)
This page took 0.030874 seconds and 4 git commands to generate.