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" |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 26 | #include "hf/vcpu.h" |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 27 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 28 | #include "vmapi/hf/ffa.h" |
Andrew Walbran | 9553492 | 2019-06-19 11:32:54 +0100 | [diff] [blame] | 29 | |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 30 | /** |
Andrew Scull | c960c03 | 2018-10-24 15:13:35 +0100 | [diff] [blame] | 31 | * Reset the register values other than the PC and argument which are set with |
| 32 | * `arch_regs_set_pc_arg()`. |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 33 | */ |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 34 | void arch_regs_reset(struct vcpu *vcpu); |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 35 | |
| 36 | /** |
Fuad Tabba | ed294af | 2019-12-20 10:43:01 +0000 | [diff] [blame] | 37 | * Updates the given registers so that when a vCPU runs, it starts off at the |
Andrew Scull | 11a4a0c | 2018-12-29 11:38:31 +0000 | [diff] [blame] | 38 | * given address (pc) with the given argument. |
| 39 | * |
| 40 | * This function must only be called on an arch_regs that is known not be in use |
| 41 | * by any other physical CPU. |
| 42 | */ |
| 43 | void arch_regs_set_pc_arg(struct arch_regs *r, ipaddr_t pc, uintreg_t arg); |
| 44 | |
| 45 | /** |
| 46 | * Updates the register holding the return value of a function. |
| 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 | */ |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 51 | void arch_regs_set_retval(struct arch_regs *r, struct ffa_value v); |
Fuad Tabba | c8eede3 | 2019-10-31 11:17:50 +0000 | [diff] [blame] | 52 | |
| 53 | /** |
| 54 | * Initialize and reset CPU-wide register values. |
| 55 | */ |
| 56 | void arch_cpu_init(void); |