Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame^] | 1 | /* |
| 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 | |
| 23 | #include "hf/addr.h" |
| 24 | |
| 25 | /** |
| 26 | * Disables interrutps. |
| 27 | */ |
| 28 | void arch_irq_disable(void); |
| 29 | |
| 30 | /** |
| 31 | * Enables interrupts. |
| 32 | */ |
| 33 | void arch_irq_enable(void); |
| 34 | |
| 35 | /** |
| 36 | * Initializes the register state for a VM. |
| 37 | */ |
| 38 | void arch_regs_init(struct arch_regs *r, bool is_primary, uint64_t vmid, |
| 39 | paddr_t table, uint32_t index); |
| 40 | |
| 41 | /** |
| 42 | * Updates the given registers so that when a vcpu runs, it starts off at the |
| 43 | * given address (pc) with the given argument. |
| 44 | * |
| 45 | * This function must only be called on an arch_regs that is known not be in use |
| 46 | * by any other physical CPU. |
| 47 | */ |
| 48 | void arch_regs_set_pc_arg(struct arch_regs *r, ipaddr_t pc, uintreg_t arg); |
| 49 | |
| 50 | /** |
| 51 | * Updates the register holding the return value of a function. |
| 52 | * |
| 53 | * This function must only be called on an arch_regs that is known not be in use |
| 54 | * by any other physical CPU. |
| 55 | */ |
| 56 | void arch_regs_set_retval(struct arch_regs *r, uintreg_t v); |