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 | * |
Andrew Walbran | e959ec1 | 2020-06-17 15:01:09 +0100 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style |
| 5 | * license that can be found in the LICENSE file or at |
| 6 | * https://opensource.org/licenses/BSD-3-Clause. |
Andrew Scull | 1883487 | 2018-10-12 11:48:09 +0100 | [diff] [blame] | 7 | */ |
| 8 | |
Andrew Scull | fbc938a | 2018-08-20 14:09:28 +0100 | [diff] [blame] | 9 | #pragma once |
Wedson Almeida Filho | 3fcbcff | 2018-07-10 23:53:39 +0100 | [diff] [blame] | 10 | |
Andrew Scull | 18c78fc | 2018-08-20 12:57:41 +0100 | [diff] [blame] | 11 | #include "hf/cpu.h" |
Wedson Almeida Filho | 22d5eaa | 2018-12-16 00:38:49 +0000 | [diff] [blame] | 12 | #include "hf/mpool.h" |
Andrew Scull | 18c78fc | 2018-08-20 12:57:41 +0100 | [diff] [blame] | 13 | #include "hf/vm.h" |
Wedson Almeida Filho | 3fcbcff | 2018-07-10 23:53:39 +0100 | [diff] [blame] | 14 | |
Andrew Scull | 6d2db33 | 2018-10-10 15:28:17 +0100 | [diff] [blame] | 15 | #include "vmapi/hf/call.h" |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 16 | #include "vmapi/hf/ffa.h" |
Andrew Scull | 6d2db33 | 2018-10-10 15:28:17 +0100 | [diff] [blame] | 17 | |
Wedson Almeida Filho | 22d5eaa | 2018-12-16 00:38:49 +0000 | [diff] [blame] | 18 | void api_init(struct mpool *ppool); |
Madhukar Pappireddy | b11e0d1 | 2021-08-02 19:44:35 -0500 | [diff] [blame] | 19 | struct vcpu *api_ffa_get_vm_vcpu(struct vm *vm, struct vcpu *current); |
Andrew Walbran | 1f8d487 | 2018-12-20 11:21:32 +0000 | [diff] [blame] | 20 | void api_regs_state_saved(struct vcpu *vcpu); |
Wedson Almeida Filho | ea62e2e | 2019-01-09 19:14:59 +0000 | [diff] [blame] | 21 | int64_t api_mailbox_writable_get(const struct vcpu *current); |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 22 | int64_t api_mailbox_waiter_get(ffa_vm_id_t vm_id, const struct vcpu *current); |
J-Alves | 27b7196 | 2022-12-12 15:29:58 +0000 | [diff] [blame] | 23 | struct vcpu *api_switch_to_primary(struct vcpu *current, |
| 24 | struct ffa_value primary_ret, |
| 25 | enum vcpu_state secondary_state); |
| 26 | |
Andrew Walbran | c1ad4ce | 2019-05-09 11:41:39 +0100 | [diff] [blame] | 27 | int64_t api_debug_log(char c, struct vcpu *current); |
Andrew Scull | 6bca35e | 2018-10-02 12:05:32 +0100 | [diff] [blame] | 28 | |
Andrew Scull | 33fecd3 | 2019-01-08 14:48:27 +0000 | [diff] [blame] | 29 | struct vcpu *api_preempt(struct vcpu *current); |
Andrew Scull | 33fecd3 | 2019-01-08 14:48:27 +0000 | [diff] [blame] | 30 | struct vcpu *api_wait_for_interrupt(struct vcpu *current); |
Andrew Walbran | 3364565 | 2019-04-15 12:29:31 +0100 | [diff] [blame] | 31 | struct vcpu *api_vcpu_off(struct vcpu *current); |
Andrew Scull | 9726c25 | 2019-01-23 13:44:19 +0000 | [diff] [blame] | 32 | struct vcpu *api_abort(struct vcpu *current); |
Andrew Walbran | 3364565 | 2019-04-15 12:29:31 +0100 | [diff] [blame] | 33 | struct vcpu *api_wake_up(struct vcpu *current, struct vcpu *target_vcpu); |
Andrew Walbran | 318f573 | 2018-11-20 16:23:42 +0000 | [diff] [blame] | 34 | |
Manish Pandey | 35e452f | 2021-02-18 21:36:34 +0000 | [diff] [blame] | 35 | int64_t api_interrupt_enable(uint32_t intid, bool enable, |
| 36 | enum interrupt_type type, struct vcpu *current); |
Wedson Almeida Filho | c559d13 | 2019-01-09 19:33:40 +0000 | [diff] [blame] | 37 | uint32_t api_interrupt_get(struct vcpu *current); |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 38 | int64_t api_interrupt_inject(ffa_vm_id_t target_vm_id, |
| 39 | ffa_vcpu_index_t target_vcpu_idx, uint32_t intid, |
Andrew Walbran | 42347a9 | 2019-05-09 13:59:03 +0100 | [diff] [blame] | 40 | struct vcpu *current, struct vcpu **next); |
Manish Pandey | a5f39fb | 2020-09-11 09:47:11 +0100 | [diff] [blame] | 41 | int64_t api_interrupt_inject_locked(struct vcpu_locked target_locked, |
| 42 | uint32_t intid, struct vcpu *current, |
| 43 | struct vcpu **next); |
J-Alves | 1339402 | 2021-06-30 13:48:49 +0100 | [diff] [blame] | 44 | void api_sri_send_if_delayed(struct vcpu *current); |
Jose Marinho | a1dfeda | 2019-02-27 16:46:03 +0000 | [diff] [blame] | 45 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 46 | struct ffa_value api_ffa_msg_send(ffa_vm_id_t sender_vm_id, |
| 47 | ffa_vm_id_t receiver_vm_id, uint32_t size, |
Federico Recanati | 86f6cde | 2022-04-28 19:44:49 +0200 | [diff] [blame] | 48 | struct vcpu *current, struct vcpu **next); |
Federico Recanati | 25053ee | 2022-03-14 15:01:53 +0100 | [diff] [blame] | 49 | struct ffa_value api_ffa_msg_send2(ffa_vm_id_t sender_vm_id, uint32_t flags, |
| 50 | struct vcpu *current); |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 51 | struct ffa_value api_ffa_msg_recv(bool block, struct vcpu *current, |
| 52 | struct vcpu **next); |
Federico Recanati | 7bef0b9 | 2022-03-17 14:56:22 +0100 | [diff] [blame] | 53 | struct ffa_value api_ffa_rx_release(ffa_vm_id_t receiver_id, |
J-Alves | e8c8c2b | 2022-12-16 15:34:48 +0000 | [diff] [blame] | 54 | struct vcpu *current); |
Federico Recanati | 644f046 | 2022-03-17 12:04:00 +0100 | [diff] [blame] | 55 | struct ffa_value api_ffa_rx_acquire(ffa_vm_id_t receiver_id, |
| 56 | struct vcpu *current); |
Manish Pandey | d34f889 | 2020-06-19 17:41:07 +0100 | [diff] [blame] | 57 | struct ffa_value api_vm_configure_pages( |
| 58 | struct mm_stage1_locked mm_stage1_locked, struct vm_locked vm_locked, |
| 59 | ipaddr_t send, ipaddr_t recv, uint32_t page_count, |
| 60 | struct mpool *local_page_pool); |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 61 | struct ffa_value api_ffa_rxtx_map(ipaddr_t send, ipaddr_t recv, |
Federico Recanati | 9f1b653 | 2022-04-14 13:15:28 +0200 | [diff] [blame] | 62 | uint32_t page_count, struct vcpu *current); |
Daniel Boulby | 9e420ca | 2021-07-07 15:03:49 +0100 | [diff] [blame] | 63 | struct ffa_value api_ffa_rxtx_unmap(ffa_vm_id_t allocator_id, |
| 64 | struct vcpu *current); |
Olivier Deprez | ee9d6a9 | 2019-11-26 09:14:11 +0000 | [diff] [blame] | 65 | struct ffa_value api_yield(struct vcpu *current, struct vcpu **next); |
Daniel Boulby | baeaf2e | 2021-12-09 11:42:36 +0000 | [diff] [blame] | 66 | struct ffa_value api_ffa_version(struct vcpu *current, |
| 67 | uint32_t requested_version); |
Fuad Tabba | e4efcc3 | 2020-07-16 15:37:27 +0100 | [diff] [blame] | 68 | struct ffa_value api_ffa_partition_info_get(struct vcpu *current, |
Daniel Boulby | b46cad1 | 2021-12-13 17:47:21 +0000 | [diff] [blame] | 69 | const struct ffa_uuid *uuid, |
| 70 | const uint32_t flags); |
Raghu Krishnamurthy | 7592bcb | 2022-12-25 13:09:00 -0800 | [diff] [blame] | 71 | struct ffa_value api_ffa_partition_info_get_regs(struct vcpu *current, |
| 72 | const struct ffa_uuid *uuid, |
| 73 | const uint16_t start_index, |
| 74 | const uint16_t tag); |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 75 | struct ffa_value api_ffa_id_get(const struct vcpu *current); |
Daniel Boulby | b2fb80e | 2021-02-03 15:09:23 +0000 | [diff] [blame] | 76 | struct ffa_value api_ffa_spm_id_get(void); |
J-Alves | 6f72ca8 | 2021-11-01 12:34:58 +0000 | [diff] [blame] | 77 | struct ffa_value api_ffa_feature_success(uint32_t arg2); |
Karl Meakin | 34b8ae9 | 2023-01-13 13:33:07 +0000 | [diff] [blame] | 78 | struct ffa_value api_ffa_features(uint32_t function_id, uint32_t input_property, |
| 79 | uint32_t ffa_version); |
Madhukar Pappireddy | 5522c67 | 2021-12-17 16:35:51 -0600 | [diff] [blame] | 80 | struct ffa_value api_ffa_msg_wait(struct vcpu *current, struct vcpu **next, |
| 81 | struct ffa_value *args); |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 82 | struct ffa_value api_ffa_run(ffa_vm_id_t vm_id, ffa_vcpu_index_t vcpu_idx, |
Madhukar Pappireddy | b11e0d1 | 2021-08-02 19:44:35 -0500 | [diff] [blame] | 83 | struct vcpu *current, struct vcpu **next); |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 84 | struct ffa_value api_ffa_mem_send(uint32_t share_func, uint32_t length, |
| 85 | uint32_t fragment_length, ipaddr_t address, |
Andrew Walbran | 1a86aa9 | 2020-05-15 17:22:28 +0100 | [diff] [blame] | 86 | uint32_t page_count, struct vcpu *current); |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 87 | struct ffa_value api_ffa_mem_retrieve_req(uint32_t length, |
| 88 | uint32_t fragment_length, |
| 89 | ipaddr_t address, uint32_t page_count, |
| 90 | struct vcpu *current); |
| 91 | struct ffa_value api_ffa_mem_relinquish(struct vcpu *current); |
| 92 | struct ffa_value api_ffa_mem_reclaim(ffa_memory_handle_t handle, |
| 93 | ffa_memory_region_flags_t flags, |
| 94 | struct vcpu *current); |
Andrew Walbran | ca808b1 | 2020-05-15 17:22:28 +0100 | [diff] [blame] | 95 | struct ffa_value api_ffa_mem_frag_rx(ffa_memory_handle_t handle, |
| 96 | uint32_t fragment_offset, |
| 97 | ffa_vm_id_t sender_vm_id, |
| 98 | struct vcpu *current); |
| 99 | struct ffa_value api_ffa_mem_frag_tx(ffa_memory_handle_t handle, |
| 100 | uint32_t fragment_length, |
| 101 | ffa_vm_id_t sender_vm_id, |
| 102 | struct vcpu *current); |
Olivier Deprez | ee9d6a9 | 2019-11-26 09:14:11 +0000 | [diff] [blame] | 103 | struct ffa_value api_ffa_msg_send_direct_req(ffa_vm_id_t sender_vm_id, |
| 104 | ffa_vm_id_t receiver_vm_id, |
| 105 | struct ffa_value args, |
| 106 | struct vcpu *current, |
| 107 | struct vcpu **next); |
| 108 | struct ffa_value api_ffa_msg_send_direct_resp(ffa_vm_id_t sender_vm_id, |
| 109 | ffa_vm_id_t receiver_vm_id, |
| 110 | struct ffa_value args, |
| 111 | struct vcpu *current, |
| 112 | struct vcpu **next); |
Max Shvetsov | 40108e7 | 2020-08-27 12:39:50 +0100 | [diff] [blame] | 113 | struct ffa_value api_ffa_secondary_ep_register(ipaddr_t entry_point, |
| 114 | struct vcpu *current); |
Manish Pandey | a5f39fb | 2020-09-11 09:47:11 +0100 | [diff] [blame] | 115 | struct vcpu *api_switch_to_other_world(struct vcpu *current, |
| 116 | struct ffa_value other_world_ret, |
| 117 | enum vcpu_state vcpu_state); |
J-Alves | a0f317d | 2021-06-09 13:31:59 +0100 | [diff] [blame] | 118 | struct ffa_value api_ffa_notification_bitmap_create(ffa_vm_id_t vm_id, |
| 119 | ffa_vcpu_count_t vcpu_count, |
| 120 | struct vcpu *current); |
| 121 | struct ffa_value api_ffa_notification_bitmap_destroy(ffa_vm_id_t vm_id, |
| 122 | struct vcpu *current); |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 123 | |
| 124 | struct ffa_value api_ffa_notification_update_bindings( |
| 125 | ffa_vm_id_t sender_vm_id, ffa_vm_id_t receiver_vm_id, uint32_t flags, |
| 126 | ffa_notifications_bitmap_t notifications, bool is_bind, |
| 127 | struct vcpu *current); |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 128 | |
| 129 | struct ffa_value api_ffa_notification_set( |
| 130 | ffa_vm_id_t sender_vm_id, ffa_vm_id_t receiver_vm_id, uint32_t flags, |
| 131 | ffa_notifications_bitmap_t notifications, struct vcpu *current); |
| 132 | |
| 133 | struct ffa_value api_ffa_notification_get(ffa_vm_id_t receiver_vm_id, |
| 134 | uint16_t vcpu_id, uint32_t flags, |
| 135 | struct vcpu *current); |
J-Alves | c8e8a22 | 2021-06-08 17:33:52 +0100 | [diff] [blame] | 136 | |
| 137 | struct ffa_value api_ffa_notification_info_get(struct vcpu *current); |
Raghu Krishnamurthy | ea6d25f | 2021-09-14 15:27:06 -0700 | [diff] [blame] | 138 | |
| 139 | struct ffa_value api_ffa_mem_perm_get(vaddr_t base_addr, struct vcpu *current); |
| 140 | struct ffa_value api_ffa_mem_perm_set(vaddr_t base_addr, uint32_t page_count, |
| 141 | uint32_t mem_perm, struct vcpu *current); |
Maksims Svecovs | 71b7670 | 2022-05-20 15:32:58 +0100 | [diff] [blame] | 142 | |
| 143 | struct ffa_value api_ffa_console_log(const struct ffa_value args, |
| 144 | struct vcpu *current); |
Madhukar Pappireddy | 2f76e49 | 2022-09-06 15:21:59 -0500 | [diff] [blame] | 145 | |
| 146 | void api_ffa_resume_direct_resp_target(struct vcpu *current, struct vcpu **next, |
| 147 | ffa_vm_id_t receiver_vm_id, |
| 148 | struct ffa_value to_ret, |
| 149 | bool is_nwd_call_chain); |