Andrew Scull | 1883487 | 2018-10-12 11:48:09 +0100 | [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 | |
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" |
| 24 | |
Wedson Almeida Filho | 22d5eaa | 2018-12-16 00:38:49 +0000 | [diff] [blame] | 25 | void api_init(struct mpool *ppool); |
Andrew Scull | 55c4d8b | 2018-12-18 18:50:18 +0000 | [diff] [blame] | 26 | int64_t api_vm_get_id(const struct vcpu *current); |
Andrew Scull | c0e569a | 2018-10-02 18:05:21 +0100 | [diff] [blame] | 27 | int64_t api_vm_get_count(void); |
Wedson Almeida Filho | 00df6c7 | 2018-10-18 11:19:24 +0100 | [diff] [blame] | 28 | int64_t api_vcpu_get_count(uint32_t vm_id, const struct vcpu *current); |
Andrew Walbran | 1f8d487 | 2018-12-20 11:21:32 +0000 | [diff] [blame^] | 29 | void api_regs_state_saved(struct vcpu *vcpu); |
Andrew Scull | 6d2db33 | 2018-10-10 15:28:17 +0100 | [diff] [blame] | 30 | struct hf_vcpu_run_return api_vcpu_run(uint32_t vm_id, uint32_t vcpu_idx, |
Andrew Scull | 38772ab | 2019-01-24 15:16:50 +0000 | [diff] [blame] | 31 | const struct vcpu *current, |
Andrew Scull | 6d2db33 | 2018-10-10 15:28:17 +0100 | [diff] [blame] | 32 | struct vcpu **next); |
Wedson Almeida Filho | ea62e2e | 2019-01-09 19:14:59 +0000 | [diff] [blame] | 33 | int64_t api_vm_configure(ipaddr_t send, ipaddr_t recv, struct vcpu *current, |
| 34 | struct vcpu **next); |
Wedson Almeida Filho | 17c997f | 2019-01-09 18:50:09 +0000 | [diff] [blame] | 35 | int64_t api_mailbox_send(uint32_t vm_id, size_t size, bool notify, |
| 36 | struct vcpu *current, struct vcpu **next); |
Andrew Scull | 6d2db33 | 2018-10-10 15:28:17 +0100 | [diff] [blame] | 37 | struct hf_mailbox_receive_return api_mailbox_receive(bool block, |
Wedson Almeida Filho | 00df6c7 | 2018-10-18 11:19:24 +0100 | [diff] [blame] | 38 | struct vcpu *current, |
Andrew Scull | 6d2db33 | 2018-10-10 15:28:17 +0100 | [diff] [blame] | 39 | struct vcpu **next); |
Wedson Almeida Filho | ea62e2e | 2019-01-09 19:14:59 +0000 | [diff] [blame] | 40 | int64_t api_mailbox_clear(struct vcpu *current, struct vcpu **next); |
| 41 | int64_t api_mailbox_writable_get(const struct vcpu *current); |
| 42 | int64_t api_mailbox_waiter_get(uint32_t vm_id, const struct vcpu *current); |
Andrew Scull | 6386f25 | 2018-12-06 13:29:10 +0000 | [diff] [blame] | 43 | int64_t api_share_memory(uint32_t vm_id, ipaddr_t addr, size_t size, |
| 44 | enum hf_share share, struct vcpu *current); |
Andrew Scull | 6bca35e | 2018-10-02 12:05:32 +0100 | [diff] [blame] | 45 | |
Andrew Scull | 33fecd3 | 2019-01-08 14:48:27 +0000 | [diff] [blame] | 46 | struct vcpu *api_preempt(struct vcpu *current); |
Andrew Scull | 33fecd3 | 2019-01-08 14:48:27 +0000 | [diff] [blame] | 47 | struct vcpu *api_wait_for_interrupt(struct vcpu *current); |
Andrew Scull | 66d62bf | 2019-02-01 13:54:10 +0000 | [diff] [blame] | 48 | struct vcpu *api_yield(struct vcpu *current); |
Andrew Scull | 9726c25 | 2019-01-23 13:44:19 +0000 | [diff] [blame] | 49 | struct vcpu *api_abort(struct vcpu *current); |
Andrew Walbran | 318f573 | 2018-11-20 16:23:42 +0000 | [diff] [blame] | 50 | |
Wedson Almeida Filho | c559d13 | 2019-01-09 19:33:40 +0000 | [diff] [blame] | 51 | int64_t api_interrupt_enable(uint32_t intid, bool enable, struct vcpu *current); |
| 52 | uint32_t api_interrupt_get(struct vcpu *current); |
| 53 | int64_t api_interrupt_inject(uint32_t target_vm_id, uint32_t target_vcpu_idx, |
Andrew Walbran | 318f573 | 2018-11-20 16:23:42 +0000 | [diff] [blame] | 54 | uint32_t intid, struct vcpu *current, |
| 55 | struct vcpu **next); |