xref: /kvmtool/arm/aarch32/arm-cpu.c (revision 85bd726a06b6e6208e24f51cea464427bb9cfe42)
1909d7f77SJonathan Austin #include "kvm/kvm.h"
2909d7f77SJonathan Austin #include "kvm/kvm-cpu.h"
3909d7f77SJonathan Austin #include "kvm/util.h"
4909d7f77SJonathan Austin 
5909d7f77SJonathan Austin #include "arm-common/gic.h"
6909d7f77SJonathan Austin #include "arm-common/timer.h"
7909d7f77SJonathan Austin 
8909d7f77SJonathan Austin #include <linux/byteorder.h>
9909d7f77SJonathan Austin #include <linux/types.h>
10909d7f77SJonathan Austin 
11909d7f77SJonathan Austin static void generate_fdt_nodes(void *fdt, struct kvm *kvm, u32 gic_phandle)
12909d7f77SJonathan Austin {
13909d7f77SJonathan Austin 	int timer_interrupts[4] = {13, 14, 11, 10};
14909d7f77SJonathan Austin 
15909d7f77SJonathan Austin 	gic__generate_fdt_nodes(fdt, gic_phandle);
16909d7f77SJonathan Austin 	timer__generate_fdt_nodes(fdt, kvm, timer_interrupts);
17909d7f77SJonathan Austin }
18909d7f77SJonathan Austin 
19909d7f77SJonathan Austin static int arm_cpu__vcpu_init(struct kvm_cpu *vcpu)
20909d7f77SJonathan Austin {
21909d7f77SJonathan Austin 	vcpu->generate_fdt_nodes = generate_fdt_nodes;
22909d7f77SJonathan Austin 	return 0;
23909d7f77SJonathan Austin }
24909d7f77SJonathan Austin 
25*85bd726aSAnup Patel static struct kvm_arm_target target_generic_v7 = {
26*85bd726aSAnup Patel 	.id		= UINT_MAX,
27*85bd726aSAnup Patel 	.compatible	= "arm,arm-v7",
28*85bd726aSAnup Patel 	.init		= arm_cpu__vcpu_init,
29*85bd726aSAnup Patel };
30*85bd726aSAnup Patel 
31909d7f77SJonathan Austin static struct kvm_arm_target target_cortex_a15 = {
32909d7f77SJonathan Austin 	.id		= KVM_ARM_TARGET_CORTEX_A15,
33909d7f77SJonathan Austin 	.compatible	= "arm,cortex-a15",
34909d7f77SJonathan Austin 	.init		= arm_cpu__vcpu_init,
35909d7f77SJonathan Austin };
36909d7f77SJonathan Austin 
376f60cca0SJonathan Austin static struct kvm_arm_target target_cortex_a7 = {
386f60cca0SJonathan Austin 	.id		= KVM_ARM_TARGET_CORTEX_A7,
396f60cca0SJonathan Austin 	.compatible	= "arm,cortex-a7",
406f60cca0SJonathan Austin 	.init		= arm_cpu__vcpu_init,
416f60cca0SJonathan Austin };
426f60cca0SJonathan Austin 
43909d7f77SJonathan Austin static int arm_cpu__core_init(struct kvm *kvm)
44909d7f77SJonathan Austin {
45*85bd726aSAnup Patel 	kvm_cpu__set_kvm_arm_generic_target(&target_generic_v7);
46*85bd726aSAnup Patel 
476f60cca0SJonathan Austin 	return (kvm_cpu__register_kvm_arm_target(&target_cortex_a15) ||
486f60cca0SJonathan Austin 		kvm_cpu__register_kvm_arm_target(&target_cortex_a7));
49909d7f77SJonathan Austin }
50909d7f77SJonathan Austin core_init(arm_cpu__core_init);
51