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 | |||||
Andrew Scull | 18c78fc | 2018-08-20 12:57:41 +0100 | [diff] [blame] | 9 | #include "hf/cpu.h" |
Andrew Scull | 18c78fc | 2018-08-20 12:57:41 +0100 | [diff] [blame] | 10 | #include "hf/vm.h" |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 11 | |
Wedson Almeida Filho | fed6902 | 2018-07-11 15:39:12 +0100 | [diff] [blame] | 12 | /** |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 13 | * 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] | 14 | * all state and return the first vCPU to run. |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 15 | */ |
Wedson Almeida Filho | 00df6c7 | 2018-10-18 11:19:24 +0100 | [diff] [blame] | 16 | struct vcpu *cpu_main(struct cpu *c) |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 17 | { |
Olivier Deprez | b9adff4 | 2021-02-01 12:14:05 +0100 | [diff] [blame] | 18 | struct vm *first_boot; |
Wedson Almeida Filho | 00df6c7 | 2018-10-18 11:19:24 +0100 | [diff] [blame] | 19 | struct vcpu *vcpu; |
Olivier Deprez | b9adff4 | 2021-02-01 12:14:05 +0100 | [diff] [blame] | 20 | |
21 | /* | ||||
22 | * This returns the PVM in the normal world and the first | ||||
23 | * booted Secure Partition in the secure world. | ||||
24 | */ | ||||
25 | first_boot = vm_get_first_boot(); | ||||
Wedson Almeida Filho | 8700964 | 2018-07-02 10:20:07 +0100 | [diff] [blame] | 26 | |
J-Alves | b37fd08 | 2020-10-22 12:29:21 +0100 | [diff] [blame] | 27 | vcpu = vm_get_vcpu(first_boot, cpu_index(c)); |
J-Alves | b37fd08 | 2020-10-22 12:29:21 +0100 | [diff] [blame] | 28 | |
Wedson Almeida Filho | 00df6c7 | 2018-10-18 11:19:24 +0100 | [diff] [blame] | 29 | vcpu->cpu = c; |
Andrew Scull | c960c03 | 2018-10-24 15:13:35 +0100 | [diff] [blame] | 30 | |
J-Alves | b37fd08 | 2020-10-22 12:29:21 +0100 | [diff] [blame] | 31 | /* Reset the registers to give a clean start for vCPU. */ |
Olivier Deprez | e6f7b9d | 2021-02-01 11:55:48 +0100 | [diff] [blame] | 32 | vcpu_reset(vcpu); |
Andrew Scull | c960c03 | 2018-10-24 15:13:35 +0100 | [diff] [blame] | 33 | |
Wedson Almeida Filho | 00df6c7 | 2018-10-18 11:19:24 +0100 | [diff] [blame] | 34 | return vcpu; |
Wedson Almeida Filho | 987c0ff | 2018-06-20 16:34:38 +0100 | [diff] [blame] | 35 | } |