blob: 2d956efbf0f521bfa350e4ce34976197706aaa8d [file] [log] [blame]
Andrew Scull18834872018-10-12 11:48:09 +01001/*
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 Scullfbc938a2018-08-20 14:09:28 +010017#pragma once
Wedson Almeida Filho3fcbcff2018-07-10 23:53:39 +010018
Andrew Scull18c78fc2018-08-20 12:57:41 +010019#include "hf/cpu.h"
Wedson Almeida Filho22d5eaa2018-12-16 00:38:49 +000020#include "hf/mpool.h"
Andrew Scull18c78fc2018-08-20 12:57:41 +010021#include "hf/vm.h"
Wedson Almeida Filho3fcbcff2018-07-10 23:53:39 +010022
Andrew Scull6d2db332018-10-10 15:28:17 +010023#include "vmapi/hf/call.h"
24
Wedson Almeida Filho22d5eaa2018-12-16 00:38:49 +000025void api_init(struct mpool *ppool);
Andrew Scull55c4d8b2018-12-18 18:50:18 +000026int64_t api_vm_get_id(const struct vcpu *current);
Andrew Scullc0e569a2018-10-02 18:05:21 +010027int64_t api_vm_get_count(void);
Wedson Almeida Filho00df6c72018-10-18 11:19:24 +010028int64_t api_vcpu_get_count(uint32_t vm_id, const struct vcpu *current);
Andrew Scull6d2db332018-10-10 15:28:17 +010029struct hf_vcpu_run_return api_vcpu_run(uint32_t vm_id, uint32_t vcpu_idx,
Andrew Scull9726c252019-01-23 13:44:19 +000030 struct vcpu *current,
Andrew Scull6d2db332018-10-10 15:28:17 +010031 struct vcpu **next);
Wedson Almeida Filhoea62e2e2019-01-09 19:14:59 +000032int64_t api_vm_configure(ipaddr_t send, ipaddr_t recv, struct vcpu *current,
33 struct vcpu **next);
Wedson Almeida Filho17c997f2019-01-09 18:50:09 +000034int64_t api_mailbox_send(uint32_t vm_id, size_t size, bool notify,
35 struct vcpu *current, struct vcpu **next);
Andrew Scull6d2db332018-10-10 15:28:17 +010036struct hf_mailbox_receive_return api_mailbox_receive(bool block,
Wedson Almeida Filho00df6c72018-10-18 11:19:24 +010037 struct vcpu *current,
Andrew Scull6d2db332018-10-10 15:28:17 +010038 struct vcpu **next);
Wedson Almeida Filhoea62e2e2019-01-09 19:14:59 +000039int64_t api_mailbox_clear(struct vcpu *current, struct vcpu **next);
40int64_t api_mailbox_writable_get(const struct vcpu *current);
41int64_t api_mailbox_waiter_get(uint32_t vm_id, const struct vcpu *current);
Andrew Scull6386f252018-12-06 13:29:10 +000042int64_t api_share_memory(uint32_t vm_id, ipaddr_t addr, size_t size,
43 enum hf_share share, struct vcpu *current);
Andrew Scull6bca35e2018-10-02 12:05:32 +010044
Andrew Scull33fecd32019-01-08 14:48:27 +000045struct vcpu *api_preempt(struct vcpu *current);
Wedson Almeida Filho00df6c72018-10-18 11:19:24 +010046struct vcpu *api_yield(struct vcpu *current);
Andrew Scull33fecd32019-01-08 14:48:27 +000047struct vcpu *api_wait_for_interrupt(struct vcpu *current);
Andrew Scull9726c252019-01-23 13:44:19 +000048struct vcpu *api_abort(struct vcpu *current);
Andrew Walbran318f5732018-11-20 16:23:42 +000049
Wedson Almeida Filhoc559d132019-01-09 19:33:40 +000050int64_t api_interrupt_enable(uint32_t intid, bool enable, struct vcpu *current);
51uint32_t api_interrupt_get(struct vcpu *current);
52int64_t api_interrupt_inject(uint32_t target_vm_id, uint32_t target_vcpu_idx,
Andrew Walbran318f5732018-11-20 16:23:42 +000053 uint32_t intid, struct vcpu *current,
54 struct vcpu **next);