blob: aba76aae6c6b6c55ca1d2e13bafae9526065e8f8 [file] [log] [blame]
Andrew Scull11a4a0c2018-12-29 11:38:31 +00001/*
2 * Copyright 2018 Google LLC
3 *
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/**
38 * Initializes the register state for a VM.
39 */
40void arch_regs_init(struct arch_regs *r, bool is_primary, uint64_t vmid,
41 paddr_t table, uint32_t index);
42
43/**
44 * Updates the given registers so that when a vcpu runs, it starts off at the
45 * given address (pc) with the given argument.
46 *
47 * This function must only be called on an arch_regs that is known not be in use
48 * by any other physical CPU.
49 */
50void arch_regs_set_pc_arg(struct arch_regs *r, ipaddr_t pc, uintreg_t arg);
51
52/**
53 * Updates the register holding the return value of a function.
54 *
55 * This function must only be called on an arch_regs that is known not be in use
56 * by any other physical CPU.
57 */
58void arch_regs_set_retval(struct arch_regs *r, uintreg_t v);