Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 1 | /* |
Andrew Walbran | 692b325 | 2019-03-07 15:51:31 +0000 | [diff] [blame] | 2 | * Copyright 2018 The Hafnium Authors. |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [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 | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #pragma once |
| 10 | |
| 11 | #include <stdbool.h> |
| 12 | #include <stddef.h> |
| 13 | #include <stdint.h> |
| 14 | |
Andrew Scull | acc1fdd | 2019-01-04 13:55:14 +0000 | [diff] [blame] | 15 | #include "hf/arch/types.h" |
| 16 | |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 17 | #include "hf/addr.h" |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 18 | #include "hf/vcpu.h" |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 19 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 20 | #include "vmapi/hf/ffa.h" |
Andrew Walbran | 9553492 | 2019-06-19 11:32:54 +0100 | [diff] [blame] | 21 | |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 22 | /** |
Andrew Scull | c960c03 | 2018-10-24 15:13:35 +0100 | [diff] [blame] | 23 | * Reset the register values other than the PC and argument which are set with |
| 24 | * `arch_regs_set_pc_arg()`. |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 25 | */ |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 26 | void arch_regs_reset(struct vcpu *vcpu); |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 27 | |
| 28 | /** |
Fuad Tabba | ed294af | 2019-12-20 10:43:01 +0000 | [diff] [blame] | 29 | * Updates the given registers so that when a vCPU runs, it starts off at the |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 30 | * given address (pc) with the given argument. |
| 31 | * |
| 32 | * This function must only be called on an arch_regs that is known not be in use |
| 33 | * by any other physical CPU. |
| 34 | */ |
| 35 | void arch_regs_set_pc_arg(struct arch_regs *r, ipaddr_t pc, uintreg_t arg); |
| 36 | |
| 37 | /** |
J-Alves | b7800a1 | 2022-01-25 17:55:53 +0000 | [diff] [blame] | 38 | * Verifies the `gp_reg_num` complies with the number of registers available in |
| 39 | * the architecture. |
| 40 | */ |
| 41 | bool arch_regs_reg_num_valid(const uint32_t gp_reg_num); |
| 42 | |
| 43 | /** |
| 44 | * Sets the value of a general purpose register. |
| 45 | */ |
| 46 | void arch_regs_set_gp_reg(struct arch_regs *r, uintreg_t value, |
| 47 | const uint32_t gp_reg_num); |
| 48 | |
| 49 | /** |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 50 | * Updates the register holding the return value of a function. |
| 51 | * |
| 52 | * This function must only be called on an arch_regs that is known not be in use |
| 53 | * by any other physical CPU. |
| 54 | */ |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 55 | void arch_regs_set_retval(struct arch_regs *r, struct ffa_value v); |
Fuad Tabba | c8eede3 | 2019-10-31 11:17:50 +0000 | [diff] [blame] | 56 | |
| 57 | /** |
Andrew Walbran | d8d3f5d | 2020-10-07 18:23:01 +0100 | [diff] [blame] | 58 | * Extracts SMC or HVC arguments from the registers of a vCPU. |
| 59 | * |
| 60 | * This function must only be called on an arch_regs that is known not be in use |
| 61 | * by any other physical CPU. |
| 62 | */ |
| 63 | struct ffa_value arch_regs_get_args(struct arch_regs *regs); |
| 64 | |
| 65 | /** |
Fuad Tabba | c8eede3 | 2019-10-31 11:17:50 +0000 | [diff] [blame] | 66 | * Initialize and reset CPU-wide register values. |
| 67 | */ |
Olivier Deprez | 148b560 | 2022-03-16 17:13:06 +0100 | [diff] [blame] | 68 | void arch_cpu_init(struct cpu *c); |
| 69 | |
| 70 | struct vcpu *arch_vcpu_resume(struct cpu *c); |