Introduce vcpu_reset and refactor arch_cpu_init
Introduce vcpu_reset calling arch_cpu_init and arch_regs_reset.
vcpu_reset is called from main on cold boot or resume from CPU off.
arch_cpu_init gets a cpu and entry point parameter passed to
PSCI resume function.
Change-Id: I809b453c32b418237b7334d13d8e55916d593b09
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/src/vcpu.c b/src/vcpu.c
index 15a6c85..6b1e161 100644
--- a/src/vcpu.c
+++ b/src/vcpu.c
@@ -8,6 +8,8 @@
#include "hf/vcpu.h"
+#include "hf/arch/cpu.h"
+
#include "hf/check.h"
#include "hf/dlog.h"
#include "hf/std.h"
@@ -193,3 +195,11 @@
return vm_get_vcpu(vm, current_cpu_index);
}
+
+void vcpu_reset(struct vcpu *vcpu)
+{
+ arch_cpu_init(vcpu->cpu, ipa_init(0));
+
+ /* Reset the registers to give a clean start for vCPU. */
+ arch_regs_reset(vcpu);
+}