blob: 2b35f020fad131f7eeab1a967155b50160fb0843 [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"
26
Andrew Walbran95534922019-06-19 11:32:54 +010027#include "vmapi/hf/spci.h"
28
Andrew Scull11a4a0c2018-12-29 11:38:31 +000029/**
Andrew Scullc960c032018-10-24 15:13:35 +010030 * Reset the register values other than the PC and argument which are set with
31 * `arch_regs_set_pc_arg()`.
Andrew Scull11a4a0c2018-12-29 11:38:31 +000032 */
Andrew Walbran95534922019-06-19 11:32:54 +010033void arch_regs_reset(struct arch_regs *r, bool is_primary, spci_vm_id_t vm_id,
Andrew Walbran4d3fa282019-06-26 13:31:15 +010034 cpu_id_t vcpu_id, paddr_t table);
Andrew Scull11a4a0c2018-12-29 11:38:31 +000035
36/**
37 * Updates the given registers so that when a vcpu runs, it starts off at the
38 * 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 Walbrand4d2fa12019-10-01 16:47:25 +010051void arch_regs_set_retval(struct arch_regs *r, struct spci_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);