blob: dabc1c5ea00d9c806d5fc9afebe89073c377c7b0 [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/**
38 * Updates the register holding the return value of a function.
39 *
40 * This function must only be called on an arch_regs that is known not be in use
41 * by any other physical CPU.
42 */
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010043void arch_regs_set_retval(struct arch_regs *r, struct ffa_value v);
Fuad Tabbac8eede32019-10-31 11:17:50 +000044
45/**
46 * Initialize and reset CPU-wide register values.
47 */
48void arch_cpu_init(void);