blob: ae0d08f0b3baaed19c2bd494877f8442da524716 [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/**
30 * Disables interrutps.
31 */
32void arch_irq_disable(void);
33
34/**
35 * Enables interrupts.
36 */
37void arch_irq_enable(void);
38
39/**
Andrew Scullc960c032018-10-24 15:13:35 +010040 * Reset the register values other than the PC and argument which are set with
41 * `arch_regs_set_pc_arg()`.
Andrew Scull11a4a0c2018-12-29 11:38:31 +000042 */
Andrew Walbran95534922019-06-19 11:32:54 +010043void arch_regs_reset(struct arch_regs *r, bool is_primary, spci_vm_id_t vm_id,
Andrew Walbran4d3fa282019-06-26 13:31:15 +010044 cpu_id_t vcpu_id, paddr_t table);
Andrew Scull11a4a0c2018-12-29 11:38:31 +000045
46/**
47 * Updates the given registers so that when a vcpu runs, it starts off at the
48 * given address (pc) with the given argument.
49 *
50 * This function must only be called on an arch_regs that is known not be in use
51 * by any other physical CPU.
52 */
53void arch_regs_set_pc_arg(struct arch_regs *r, ipaddr_t pc, uintreg_t arg);
54
55/**
56 * Updates the register holding the return value of a function.
57 *
58 * This function must only be called on an arch_regs that is known not be in use
59 * by any other physical CPU.
60 */
Andrew Walbrand4d2fa12019-10-01 16:47:25 +010061void arch_regs_set_retval(struct arch_regs *r, struct spci_value v);
Fuad Tabbac8eede32019-10-31 11:17:50 +000062
63/**
64 * Initialize and reset CPU-wide register values.
65 */
66void arch_cpu_init(void);