Andrew Scull | 1883487 | 2018-10-12 11:48:09 +0100 | [diff] [blame] | 1 | /* |
Andrew Walbran | 692b325 | 2019-03-07 15:51:31 +0000 | [diff] [blame] | 2 | * Copyright 2018 The Hafnium Authors. |
Andrew Scull | 1883487 | 2018-10-12 11:48:09 +0100 | [diff] [blame] | 3 | * |
Andrew Walbran | e959ec1 | 2020-06-17 15:01:09 +0100 | [diff] [blame] | 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. | ||||
Andrew Scull | 1883487 | 2018-10-12 11:48:09 +0100 | [diff] [blame] | 7 | */ |
8 | |||||
J-Alves | 1339402 | 2021-06-30 13:48:49 +0100 | [diff] [blame] | 9 | #include "hf/arch/plat/ffa.h" |
10 | |||||
Andrew Scull | 18c78fc | 2018-08-20 12:57:41 +0100 | [diff] [blame] | 11 | #include "hf/cpu.h" |
J-Alves | 1339402 | 2021-06-30 13:48:49 +0100 | [diff] [blame] | 12 | #include "hf/dlog.h" |
Andrew Scull | 18c78fc | 2018-08-20 12:57:41 +0100 | [diff] [blame] | 13 | #include "hf/vm.h" |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 14 | |
J-Alves | 1339402 | 2021-06-30 13:48:49 +0100 | [diff] [blame] | 15 | #include "vmapi/hf/ffa.h" |
16 | |||||
Wedson Almeida Filho | fed6902 | 2018-07-11 15:39:12 +0100 | [diff] [blame] | 17 | /** |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 18 | * The entry point of CPUs when they are turned on. It is supposed to initialise |
Wedson Almeida Filho | 8700964 | 2018-07-02 10:20:07 +0100 | [diff] [blame] | 19 | * all state and return the first vCPU to run. |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 20 | */ |
Wedson Almeida Filho | 00df6c7 | 2018-10-18 11:19:24 +0100 | [diff] [blame] | 21 | struct vcpu *cpu_main(struct cpu *c) |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 22 | { |
Olivier Deprez | b9adff4 | 2021-02-01 12:14:05 +0100 | [diff] [blame] | 23 | struct vm *first_boot; |
Wedson Almeida Filho | 00df6c7 | 2018-10-18 11:19:24 +0100 | [diff] [blame] | 24 | struct vcpu *vcpu; |
Olivier Deprez | b9adff4 | 2021-02-01 12:14:05 +0100 | [diff] [blame] | 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(); | ||||
Wedson Almeida Filho | 8700964 | 2018-07-02 10:20:07 +0100 | [diff] [blame] | 31 | |
J-Alves | b37fd08 | 2020-10-22 12:29:21 +0100 | [diff] [blame] | 32 | vcpu = vm_get_vcpu(first_boot, cpu_index(c)); |
J-Alves | b37fd08 | 2020-10-22 12:29:21 +0100 | [diff] [blame] | 33 | |
Wedson Almeida Filho | 00df6c7 | 2018-10-18 11:19:24 +0100 | [diff] [blame] | 34 | vcpu->cpu = c; |
Andrew Scull | c960c03 | 2018-10-24 15:13:35 +0100 | [diff] [blame] | 35 | |
J-Alves | b37fd08 | 2020-10-22 12:29:21 +0100 | [diff] [blame] | 36 | /* Reset the registers to give a clean start for vCPU. */ |
Olivier Deprez | e6f7b9d | 2021-02-01 11:55:48 +0100 | [diff] [blame] | 37 | vcpu_reset(vcpu); |
Andrew Scull | c960c03 | 2018-10-24 15:13:35 +0100 | [diff] [blame] | 38 | |
J-Alves | 7ac4905 | 2022-02-08 17:20:53 +0000 | [diff] [blame] | 39 | /* Set the designated GP with the physical core index. */ |
40 | vcpu_set_phys_core_idx(vcpu); | ||||
41 | |||||
J-Alves | 1339402 | 2021-06-30 13:48:49 +0100 | [diff] [blame] | 42 | /* Initialize SRI for running core. */ |
43 | plat_ffa_sri_init(c); | ||||
44 | |||||
J-Alves | 7e67d10 | 2022-04-13 13:22:39 +0100 | [diff] [blame^] | 45 | vm_set_boot_info_gp_reg(first_boot, vcpu); |
46 | |||||
Wedson Almeida Filho | 00df6c7 | 2018-10-18 11:19:24 +0100 | [diff] [blame] | 47 | return vcpu; |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 48 | } |