Andrew Scull | 1883487 | 2018-10-12 11:48:09 +0100 | [diff] [blame] | 1 | /* |
Andrew Walbran | 692b325 | 2019-03-07 15:51:31 +0000 | [diff] [blame] | 2 | * Copyright 2018 The Hafnium Authors. |
Andrew Scull | 1883487 | 2018-10-12 11:48:09 +0100 | [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 | |
Andrew Scull | fbc938a | 2018-08-20 14:09:28 +0100 | [diff] [blame] | 17 | #pragma once |
Wedson Almeida Filho | 3fcbcff | 2018-07-10 23:53:39 +0100 | [diff] [blame] | 18 | |
Andrew Scull | 18c78fc | 2018-08-20 12:57:41 +0100 | [diff] [blame] | 19 | #include "hf/cpu.h" |
Wedson Almeida Filho | 22d5eaa | 2018-12-16 00:38:49 +0000 | [diff] [blame] | 20 | #include "hf/mpool.h" |
Andrew Scull | 18c78fc | 2018-08-20 12:57:41 +0100 | [diff] [blame] | 21 | #include "hf/vm.h" |
Wedson Almeida Filho | 3fcbcff | 2018-07-10 23:53:39 +0100 | [diff] [blame] | 22 | |
Andrew Scull | 6d2db33 | 2018-10-10 15:28:17 +0100 | [diff] [blame] | 23 | #include "vmapi/hf/call.h" |
Andrew Walbran | 7f920af | 2019-09-03 17:09:30 +0100 | [diff] [blame] | 24 | #include "vmapi/hf/spci.h" |
Andrew Scull | 6d2db33 | 2018-10-10 15:28:17 +0100 | [diff] [blame] | 25 | |
Wedson Almeida Filho | 22d5eaa | 2018-12-16 00:38:49 +0000 | [diff] [blame] | 26 | void api_init(struct mpool *ppool); |
Andrew Walbran | 52d9967 | 2019-06-25 15:51:11 +0100 | [diff] [blame] | 27 | spci_vm_count_t api_vm_get_count(void); |
Andrew Walbran | c6d23c4 | 2019-06-26 13:30:42 +0100 | [diff] [blame] | 28 | spci_vcpu_count_t api_vcpu_get_count(spci_vm_id_t vm_id, |
| 29 | const struct vcpu *current); |
Andrew Walbran | 1f8d487 | 2018-12-20 11:21:32 +0000 | [diff] [blame] | 30 | void api_regs_state_saved(struct vcpu *vcpu); |
Wedson Almeida Filho | ea62e2e | 2019-01-09 19:14:59 +0000 | [diff] [blame] | 31 | int64_t api_mailbox_writable_get(const struct vcpu *current); |
Andrew Walbran | 42347a9 | 2019-05-09 13:59:03 +0100 | [diff] [blame] | 32 | int64_t api_mailbox_waiter_get(spci_vm_id_t vm_id, const struct vcpu *current); |
Andrew Walbran | c1ad4ce | 2019-05-09 11:41:39 +0100 | [diff] [blame] | 33 | int64_t api_debug_log(char c, struct vcpu *current); |
Andrew Scull | 6bca35e | 2018-10-02 12:05:32 +0100 | [diff] [blame] | 34 | |
Andrew Scull | 33fecd3 | 2019-01-08 14:48:27 +0000 | [diff] [blame] | 35 | struct vcpu *api_preempt(struct vcpu *current); |
Andrew Scull | 33fecd3 | 2019-01-08 14:48:27 +0000 | [diff] [blame] | 36 | struct vcpu *api_wait_for_interrupt(struct vcpu *current); |
Andrew Walbran | 3364565 | 2019-04-15 12:29:31 +0100 | [diff] [blame] | 37 | struct vcpu *api_vcpu_off(struct vcpu *current); |
Andrew Scull | 9726c25 | 2019-01-23 13:44:19 +0000 | [diff] [blame] | 38 | struct vcpu *api_abort(struct vcpu *current); |
Andrew Walbran | 3364565 | 2019-04-15 12:29:31 +0100 | [diff] [blame] | 39 | struct vcpu *api_wake_up(struct vcpu *current, struct vcpu *target_vcpu); |
Andrew Walbran | 318f573 | 2018-11-20 16:23:42 +0000 | [diff] [blame] | 40 | |
Wedson Almeida Filho | c559d13 | 2019-01-09 19:33:40 +0000 | [diff] [blame] | 41 | int64_t api_interrupt_enable(uint32_t intid, bool enable, struct vcpu *current); |
| 42 | uint32_t api_interrupt_get(struct vcpu *current); |
Andrew Walbran | 42347a9 | 2019-05-09 13:59:03 +0100 | [diff] [blame] | 43 | int64_t api_interrupt_inject(spci_vm_id_t target_vm_id, |
Andrew Walbran | b037d5b | 2019-06-25 17:19:41 +0100 | [diff] [blame] | 44 | spci_vcpu_index_t target_vcpu_idx, uint32_t intid, |
Andrew Walbran | 42347a9 | 2019-05-09 13:59:03 +0100 | [diff] [blame] | 45 | struct vcpu *current, struct vcpu **next); |
Jose Marinho | a1dfeda | 2019-02-27 16:46:03 +0000 | [diff] [blame] | 46 | |
Andrew Walbran | 70bc862 | 2019-10-07 14:15:58 +0100 | [diff] [blame] | 47 | struct spci_value api_spci_msg_send(spci_vm_id_t sender_vm_id, |
| 48 | spci_vm_id_t receiver_vm_id, uint32_t size, |
| 49 | uint32_t attributes, struct vcpu *current, |
| 50 | struct vcpu **next); |
Andrew Walbran | d4d2fa1 | 2019-10-01 16:47:25 +0100 | [diff] [blame] | 51 | struct spci_value api_spci_msg_recv(bool block, struct vcpu *current, |
| 52 | struct vcpu **next); |
Andrew Walbran | 8a0f5ca | 2019-11-05 13:12:23 +0000 | [diff] [blame] | 53 | struct spci_value api_spci_rx_release(struct vcpu *current, struct vcpu **next); |
Andrew Walbran | bfffb0f | 2019-11-05 14:02:34 +0000 | [diff] [blame] | 54 | struct spci_value api_spci_rxtx_map(ipaddr_t send, ipaddr_t recv, |
| 55 | uint32_t page_count, struct vcpu *current, |
| 56 | struct vcpu **next); |
Andrew Walbran | 16075b6 | 2019-09-03 17:11:07 +0100 | [diff] [blame] | 57 | void api_yield(struct vcpu *current, struct vcpu **next); |
Andrew Walbran | 7f920af | 2019-09-03 17:09:30 +0100 | [diff] [blame] | 58 | struct spci_value api_spci_version(void); |
Andrew Walbran | d230f66 | 2019-10-07 18:03:36 +0100 | [diff] [blame] | 59 | struct spci_value api_spci_id_get(const struct vcpu *current); |
Jose Marinho | c0f4ff2 | 2019-10-09 10:37:42 +0100 | [diff] [blame] | 60 | struct spci_value api_spci_features(uint32_t function_id); |
Andrew Walbran | 7a1ea0b | 2019-10-02 18:18:44 +0100 | [diff] [blame] | 61 | struct spci_value api_spci_run(spci_vm_id_t vm_id, spci_vcpu_index_t vcpu_idx, |
| 62 | const struct vcpu *current, struct vcpu **next); |
Andrew Walbran | e7ad3c0 | 2019-12-24 17:03:04 +0000 | [diff] [blame] | 63 | struct spci_value api_spci_mem_send(uint32_t share_func, ipaddr_t address, |
Andrew Walbran | e908c4a | 2019-12-02 17:13:47 +0000 | [diff] [blame] | 64 | uint32_t page_count, |
Andrew Walbran | 0f6cede | 2020-01-10 15:38:09 +0000 | [diff] [blame] | 65 | uint32_t fragment_length, uint32_t length, |
| 66 | uint32_t cookie, struct vcpu *current, |
| 67 | struct vcpu **next); |