1 /* 2 * Copyright 2018 The Hafnium Authors. 3 * 4 * Use of this source code is governed by a BSD-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/BSD-3-Clause. 7 */ 8 9 #include "hf/arch/plat/ffa.h" 10 11 #include "hf/cpu.h" 12 #include "hf/dlog.h" 13 #include "hf/vm.h" 14 15 #include "vmapi/hf/ffa.h" 16 17 /** 18 * The entry point of CPUs when they are turned on. It is supposed to initialise 19 * all state and return the first vCPU to run. 20 */ cpu_main(struct cpu * c)21struct vcpu *cpu_main(struct cpu *c) 22 { 23 struct vm *first_boot; 24 struct vcpu *vcpu; 25 26 /* 27 * This returns the PVM in the normal world and the first 28 * booted Secure Partition in the secure world. 29 */ 30 first_boot = vm_get_first_boot(); 31 32 vcpu = vm_get_vcpu(first_boot, cpu_index(c)); 33 34 vcpu->cpu = c; 35 36 /* Reset the registers to give a clean start for vCPU. */ 37 vcpu_reset(vcpu); 38 39 /* Set the designated GP with the physical core index. */ 40 vcpu_set_phys_core_idx(vcpu); 41 42 /* Initialize SRI for running core. */ 43 plat_ffa_sri_init(c); 44 45 vm_set_boot_info_gp_reg(first_boot, vcpu); 46 47 return vcpu; 48 } 49