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 #pragma once 10 11 #include <stdbool.h> 12 #include <stddef.h> 13 #include <stdint.h> 14 15 #include "hf/arch/types.h" 16 17 #include "hf/addr.h" 18 #include "hf/vcpu.h" 19 20 #include "vmapi/hf/ffa.h" 21 22 /** 23 * Reset the register values other than the PC and argument which are set with 24 * `arch_regs_set_pc_arg()`. 25 */ 26 void arch_regs_reset(struct vcpu *vcpu); 27 28 /** 29 * Updates the given registers so that when a vCPU runs, it starts off at the 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 /** 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 /** 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 */ 55 void arch_regs_set_retval(struct arch_regs *r, struct ffa_value v); 56 57 /** 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 /** 66 * Initialize and reset CPU-wide register values. 67 */ 68 void arch_cpu_init(struct cpu *c, ipaddr_t entry_point); 69