Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 1 | /* |
Andrew Walbran | 692b325 | 2019-03-07 15:51:31 +0000 | [diff] [blame^] | 2 | * Copyright 2018 The Hafnium Authors. |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 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 Scull | acc1fdd | 2019-01-04 13:55:14 +0000 | [diff] [blame] | 23 | #include "hf/arch/types.h" |
| 24 | |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 25 | #include "hf/addr.h" |
| 26 | |
| 27 | /** |
| 28 | * Disables interrutps. |
| 29 | */ |
| 30 | void arch_irq_disable(void); |
| 31 | |
| 32 | /** |
| 33 | * Enables interrupts. |
| 34 | */ |
| 35 | void arch_irq_enable(void); |
| 36 | |
| 37 | /** |
Andrew Scull | c960c03 | 2018-10-24 15:13:35 +0100 | [diff] [blame] | 38 | * Reset the register values other than the PC and argument which are set with |
| 39 | * `arch_regs_set_pc_arg()`. |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 40 | */ |
Andrew Scull | bb3ab6c | 2018-11-26 20:38:49 +0000 | [diff] [blame] | 41 | void arch_regs_reset(struct arch_regs *r, bool is_primary, uint64_t vm_id, |
| 42 | uint64_t vcpu_id, paddr_t table); |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 43 | |
| 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 | */ |
| 51 | void 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 | */ |
| 59 | void arch_regs_set_retval(struct arch_regs *r, uintreg_t v); |