4 * Copyright (c) 2013 Linaro Ltd
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.
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.
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>
22 #include "qemu-common.h"
23 #if !defined(CONFIG_USER_ONLY)
24 #include "hw/loader.h"
26 #include "hw/arm/arm.h"
27 #include "sysemu/sysemu.h"
28 #include "sysemu/kvm.h"
30 static inline void set_feature(CPUARMState
*env
, int feature
)
32 env
->features
|= 1ULL << feature
;
35 #ifdef CONFIG_USER_ONLY
36 static void aarch64_any_initfn(Object
*obj
)
38 ARMCPU
*cpu
= ARM_CPU(obj
);
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
);
51 typedef struct ARMCPUInfo
{
53 void (*initfn
)(Object
*obj
);
54 void (*class_init
)(ObjectClass
*oc
, void *data
);
57 static const ARMCPUInfo aarch64_cpus
[] = {
58 #ifdef CONFIG_USER_ONLY
59 { .name
= "any", .initfn
= aarch64_any_initfn
},
63 static void aarch64_cpu_initfn(Object
*obj
)
67 static void aarch64_cpu_finalizefn(Object
*obj
)
71 static void aarch64_cpu_class_init(ObjectClass
*oc
, void *data
)
75 static void aarch64_cpu_register(const ARMCPUInfo
*info
)
77 TypeInfo type_info
= {
78 .parent
= TYPE_AARCH64_CPU
,
79 .instance_size
= sizeof(ARMCPU
),
80 .instance_init
= info
->initfn
,
81 .class_size
= sizeof(ARMCPUClass
),
82 .class_init
= info
->class_init
,
85 type_info
.name
= g_strdup_printf("%s-" TYPE_ARM_CPU
, info
->name
);
86 type_register(&type_info
);
87 g_free((void *)type_info
.name
);
90 static const TypeInfo aarch64_cpu_type_info
= {
91 .name
= TYPE_AARCH64_CPU
,
92 .parent
= TYPE_ARM_CPU
,
93 .instance_size
= sizeof(ARMCPU
),
94 .instance_init
= aarch64_cpu_initfn
,
95 .instance_finalize
= aarch64_cpu_finalizefn
,
97 .class_size
= sizeof(AArch64CPUClass
),
98 .class_init
= aarch64_cpu_class_init
,
101 static void aarch64_cpu_register_types(void)
105 type_register_static(&aarch64_cpu_type_info
);
106 for (i
= 0; i
< ARRAY_SIZE(aarch64_cpus
); i
++) {
107 aarch64_cpu_register(&aarch64_cpus
[i
]);
111 type_init(aarch64_cpu_register_types
)