xref: /kvmtool/arm/aarch32/arm-cpu.c (revision 04ecf98aa44f5b9c9cab82168db8bd69239a382a)
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 
generate_fdt_nodes(void * fdt,struct kvm * kvm)110063d50cSAndre Przywara static void generate_fdt_nodes(void *fdt, struct kvm *kvm)
12909d7f77SJonathan Austin {
13909d7f77SJonathan Austin 	int timer_interrupts[4] = {13, 14, 11, 10};
14909d7f77SJonathan Austin 
15*04ecf98aSVladimir Murzin 	gic__generate_fdt_nodes(fdt, kvm->cfg.arch.irqchip);
16909d7f77SJonathan Austin 	timer__generate_fdt_nodes(fdt, kvm, timer_interrupts);
17909d7f77SJonathan Austin }
18909d7f77SJonathan Austin 
arm_cpu__vcpu_init(struct kvm_cpu * vcpu)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 
2585bd726aSAnup Patel static struct kvm_arm_target target_generic_v7 = {
2685bd726aSAnup Patel 	.id		= UINT_MAX,
2785bd726aSAnup Patel 	.compatible	= "arm,arm-v7",
2885bd726aSAnup Patel 	.init		= arm_cpu__vcpu_init,
2985bd726aSAnup Patel };
3085bd726aSAnup 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 
arm_cpu__core_init(struct kvm * kvm)43909d7f77SJonathan Austin static int arm_cpu__core_init(struct kvm *kvm)
44909d7f77SJonathan Austin {
4585bd726aSAnup Patel 	kvm_cpu__set_kvm_arm_generic_target(&target_generic_v7);
4685bd726aSAnup 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