blob: ccacbbb073bade4a339c8f9c7aab8a963c6742d1 [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
27/**
28 * Disables interrutps.
29 */
30void arch_irq_disable(void);
31
32/**
33 * Enables interrupts.
34 */
35void arch_irq_enable(void);
36
37/**
Andrew Scullc960c032018-10-24 15:13:35 +010038 * Reset the register values other than the PC and argument which are set with
39 * `arch_regs_set_pc_arg()`.
Andrew Scull11a4a0c2018-12-29 11:38:31 +000040 */
Andrew Scullbb3ab6c2018-11-26 20:38:49 +000041void arch_regs_reset(struct arch_regs *r, bool is_primary, uint64_t vm_id,
42 uint64_t vcpu_id, paddr_t table);
Andrew Scull11a4a0c2018-12-29 11:38:31 +000043
44/**
45 * Updates the given registers so that when a vcpu runs, it starts off at the
46 * given address (pc) with the given argument.
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 */
51void arch_regs_set_pc_arg(struct arch_regs *r, ipaddr_t pc, uintreg_t arg);
52
53/**
54 * Updates the register holding the return value of a function.
55 *
56 * This function must only be called on an arch_regs that is known not be in use
57 * by any other physical CPU.
58 */
59void arch_regs_set_retval(struct arch_regs *r, uintreg_t v);