blob: 171abaa338bae8b3cde74fe212a8b0ce5c5c9084 [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 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <stdbool.h>
20#include <stddef.h>
21#include <stdint.h>
22
Andrew Scullacc1fdd2019-01-04 13:55:14 +000023#include "hf/arch/types.h"
24
Andrew Scull11a4a0c2018-12-29 11:38:31 +000025#include "hf/addr.h"
Fuad Tabba5c738432019-12-02 11:02:42 +000026#include "hf/vcpu.h"
Andrew Scull11a4a0c2018-12-29 11:38:31 +000027
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010028#include "vmapi/hf/ffa.h"
Andrew Walbran95534922019-06-19 11:32:54 +010029
Andrew Scull11a4a0c2018-12-29 11:38:31 +000030/**
Andrew Scullc960c032018-10-24 15:13:35 +010031 * Reset the register values other than the PC and argument which are set with
32 * `arch_regs_set_pc_arg()`.
Andrew Scull11a4a0c2018-12-29 11:38:31 +000033 */
Fuad Tabba5c738432019-12-02 11:02:42 +000034void arch_regs_reset(struct vcpu *vcpu);
Andrew Scull11a4a0c2018-12-29 11:38:31 +000035
36/**
Fuad Tabbaed294af2019-12-20 10:43:01 +000037 * Updates the given registers so that when a vCPU runs, it starts off at the
Andrew Scull11a4a0c2018-12-29 11:38:31 +000038 * given address (pc) with the given argument.
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 */
43void arch_regs_set_pc_arg(struct arch_regs *r, ipaddr_t pc, uintreg_t arg);
44
45/**
46 * Updates the register holding the return value of a function.
47 *
48 * This function must only be called on an arch_regs that is known not be in use
49 * by any other physical CPU.
50 */
Andrew Walbranb5ab43c2020-04-30 11:32:54 +010051void arch_regs_set_retval(struct arch_regs *r, struct ffa_value v);
Fuad Tabbac8eede32019-10-31 11:17:50 +000052
53/**
54 * Initialize and reset CPU-wide register values.
55 */
56void arch_cpu_init(void);