blob: 65ec8d5326929ea57571f7aa49d27eb14d07ad52 [file] [log] [blame]
Andrew Scull11a4a0c2018-12-29 11:38:31 +00001/*
Andrew Walbran692b3252019-03-07 15:51:31 +00002 * Copyright 2018 The Hafnium Authors.
Andrew Scull11a4a0c2018-12-29 11:38:31 +00003 *
Andrew Walbrane959ec12020-06-17 15:01:09 +01004 * 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 Scull11a4a0c2018-12-29 11:38:31 +00007 */
8
9#pragma once
10
11#include <stdbool.h>
12#include <stddef.h>
13#include <stdint.h>
14
Andrew Scullacc1fdd2019-01-04 13:55:14 +000015#include "hf/arch/types.h"
16
Andrew Scull11a4a0c2018-12-29 11:38:31 +000017#include "hf/addr.h"
Fuad Tabba5c738432019-12-02 11:02:42 +000018#include "hf/vcpu.h"
Andrew Scull11a4a0c2018-12-29 11:38:31 +000019
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010020#include "vmapi/hf/ffa.h"
Andrew Walbran95534922019-06-19 11:32:54 +010021
Andrew Scull11a4a0c2018-12-29 11:38:31 +000022/**
Andrew Scullc960c032018-10-24 15:13:35 +010023 * Reset the register values other than the PC and argument which are set with
24 * `arch_regs_set_pc_arg()`.
Andrew Scull11a4a0c2018-12-29 11:38:31 +000025 */
Fuad Tabba5c738432019-12-02 11:02:42 +000026void arch_regs_reset(struct vcpu *vcpu);
Andrew Scull11a4a0c2018-12-29 11:38:31 +000027
28/**
Fuad Tabbaed294af2019-12-20 10:43:01 +000029 * Updates the given registers so that when a vCPU runs, it starts off at the
Andrew Scull11a4a0c2018-12-29 11:38:31 +000030 * 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 */
35void arch_regs_set_pc_arg(struct arch_regs *r, ipaddr_t pc, uintreg_t arg);
36
37/**
J-Alvesb7800a12022-01-25 17:55:53 +000038 * Verifies the `gp_reg_num` complies with the number of registers available in
39 * the architecture.
40 */
41bool arch_regs_reg_num_valid(const uint32_t gp_reg_num);
42
43/**
44 * Sets the value of a general purpose register.
45 */
46void arch_regs_set_gp_reg(struct arch_regs *r, uintreg_t value,
47 const uint32_t gp_reg_num);
48
49/**
Andrew Scull11a4a0c2018-12-29 11:38:31 +000050 * 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 Walbranb5ab43c2020-04-30 11:32:54 +010055void arch_regs_set_retval(struct arch_regs *r, struct ffa_value v);
Fuad Tabbac8eede32019-10-31 11:17:50 +000056
57/**
Andrew Walbrand8d3f5d2020-10-07 18:23:01 +010058 * 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 */
63struct ffa_value arch_regs_get_args(struct arch_regs *regs);
64
65/**
Fuad Tabbac8eede32019-10-31 11:17:50 +000066 * Initialize and reset CPU-wide register values.
67 */
Olivier Deprez148b5602022-03-16 17:13:06 +010068void arch_cpu_init(struct cpu *c);
69
70struct vcpu *arch_vcpu_resume(struct cpu *c);