blob: 9de392823e61cb4b7e46c4f76c5a4d936cfb98e7 [file] [log] [blame]
Andrew Scull18834872018-10-12 11:48:09 +01001/*
Andrew Walbran692b3252019-03-07 15:51:31 +00002 * Copyright 2018 The Hafnium Authors.
Andrew Scull18834872018-10-12 11:48:09 +01003 *
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"
Andrew Walbran7f920af2019-09-03 17:09:30 +010024#include "vmapi/hf/spci.h"
Andrew Scull6d2db332018-10-10 15:28:17 +010025
Wedson Almeida Filho22d5eaa2018-12-16 00:38:49 +000026void api_init(struct mpool *ppool);
Andrew Walbran52d99672019-06-25 15:51:11 +010027spci_vm_count_t api_vm_get_count(void);
Andrew Walbranc6d23c42019-06-26 13:30:42 +010028spci_vcpu_count_t api_vcpu_get_count(spci_vm_id_t vm_id,
29 const struct vcpu *current);
Andrew Walbran1f8d4872018-12-20 11:21:32 +000030void api_regs_state_saved(struct vcpu *vcpu);
Wedson Almeida Filhoea62e2e2019-01-09 19:14:59 +000031int64_t api_mailbox_writable_get(const struct vcpu *current);
Andrew Walbran42347a92019-05-09 13:59:03 +010032int64_t api_mailbox_waiter_get(spci_vm_id_t vm_id, const struct vcpu *current);
Andrew Walbranc1ad4ce2019-05-09 11:41:39 +010033int64_t api_debug_log(char c, struct vcpu *current);
Andrew Scull6bca35e2018-10-02 12:05:32 +010034
Andrew Scull33fecd32019-01-08 14:48:27 +000035struct vcpu *api_preempt(struct vcpu *current);
Andrew Scull33fecd32019-01-08 14:48:27 +000036struct vcpu *api_wait_for_interrupt(struct vcpu *current);
Andrew Walbran33645652019-04-15 12:29:31 +010037struct vcpu *api_vcpu_off(struct vcpu *current);
Andrew Scull9726c252019-01-23 13:44:19 +000038struct vcpu *api_abort(struct vcpu *current);
Andrew Walbran33645652019-04-15 12:29:31 +010039struct vcpu *api_wake_up(struct vcpu *current, struct vcpu *target_vcpu);
Andrew Walbran318f5732018-11-20 16:23:42 +000040
Wedson Almeida Filhoc559d132019-01-09 19:33:40 +000041int64_t api_interrupt_enable(uint32_t intid, bool enable, struct vcpu *current);
42uint32_t api_interrupt_get(struct vcpu *current);
Andrew Walbran42347a92019-05-09 13:59:03 +010043int64_t api_interrupt_inject(spci_vm_id_t target_vm_id,
Andrew Walbranb037d5b2019-06-25 17:19:41 +010044 spci_vcpu_index_t target_vcpu_idx, uint32_t intid,
Andrew Walbran42347a92019-05-09 13:59:03 +010045 struct vcpu *current, struct vcpu **next);
Jose Marinhoa1dfeda2019-02-27 16:46:03 +000046
Andrew Walbran70bc8622019-10-07 14:15:58 +010047struct 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 Walbrand4d2fa12019-10-01 16:47:25 +010051struct spci_value api_spci_msg_recv(bool block, struct vcpu *current,
52 struct vcpu **next);
Andrew Walbran8a0f5ca2019-11-05 13:12:23 +000053struct spci_value api_spci_rx_release(struct vcpu *current, struct vcpu **next);
Andrew Walbranbfffb0f2019-11-05 14:02:34 +000054struct 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 Walbran16075b62019-09-03 17:11:07 +010057void api_yield(struct vcpu *current, struct vcpu **next);
Andrew Walbran7f920af2019-09-03 17:09:30 +010058struct spci_value api_spci_version(void);
Andrew Walbrand230f662019-10-07 18:03:36 +010059struct spci_value api_spci_id_get(const struct vcpu *current);
Jose Marinhoc0f4ff22019-10-09 10:37:42 +010060struct spci_value api_spci_features(uint32_t function_id);
Andrew Walbran7a1ea0b2019-10-02 18:18:44 +010061struct 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 Walbrane7ad3c02019-12-24 17:03:04 +000063struct spci_value api_spci_mem_send(uint32_t share_func, ipaddr_t address,
Andrew Walbrane908c4a2019-12-02 17:13:47 +000064 uint32_t page_count,
Andrew Walbran0f6cede2020-01-10 15:38:09 +000065 uint32_t fragment_length, uint32_t length,
Andrew Walbran382e9182020-03-04 11:27:27 +000066 spci_cookie_t cookie, struct vcpu *current,
Andrew Walbran0f6cede2020-01-10 15:38:09 +000067 struct vcpu **next);
Andrew Walbran382e9182020-03-04 11:27:27 +000068struct spci_value api_spci_mem_retrieve_req(
69 ipaddr_t address, uint32_t page_count, uint32_t fragment_length,
70 uint32_t length, spci_cookie_t cookie, struct vcpu *current);
Andrew Walbran5de9c3d2020-02-10 13:35:29 +000071struct spci_value api_spci_mem_relinquish(struct vcpu *current);
72struct spci_value api_spci_mem_reclaim(uint32_t handle, uint32_t flags,
73 struct vcpu *current);