1 /* 2 * Copyright 2018 The Hafnium Authors. 3 * 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. 7 */ 8 9 #pragma once 10 11 #include "hf/cpu.h" 12 #include "hf/mpool.h" 13 #include "hf/vcpu.h" 14 #include "hf/vm.h" 15 16 #include "vmapi/hf/call.h" 17 #include "vmapi/hf/ffa.h" 18 19 void api_init(struct mpool *ppool); 20 struct vcpu *api_ffa_get_vm_vcpu(struct vm *vm, struct vcpu *current); 21 void api_regs_state_saved(struct vcpu *vcpu); 22 int64_t api_mailbox_writable_get(const struct vcpu *current); 23 int64_t api_mailbox_waiter_get(ffa_id_t vm_id, const struct vcpu *current); 24 struct vcpu *api_switch_to_vm(struct vcpu_locked current_locked, 25 struct ffa_value to_ret, 26 enum vcpu_state vcpu_state, ffa_id_t to_id); 27 struct vcpu *api_switch_to_primary(struct vcpu_locked current_locked, 28 struct ffa_value primary_ret, 29 enum vcpu_state secondary_state); 30 31 struct vcpu *api_preempt(struct vcpu *current); 32 struct vcpu *api_wait_for_interrupt(struct vcpu *current); 33 struct vcpu *api_vcpu_off(struct vcpu *current); 34 struct vcpu *api_abort(struct vcpu *current); 35 struct vcpu *api_wake_up(struct vcpu *current, struct vcpu *target_vcpu); 36 37 int64_t api_interrupt_enable(uint32_t intid, bool enable, 38 enum interrupt_type type, struct vcpu *current); 39 uint32_t api_interrupt_get(struct vcpu *current); 40 int64_t api_interrupt_inject(ffa_id_t target_vm_id, 41 ffa_vcpu_index_t target_vcpu_idx, uint32_t intid, 42 struct vcpu *current, struct vcpu **next); 43 int64_t api_interrupt_inject_locked(struct vcpu_locked target_locked, 44 uint32_t intid, 45 struct vcpu_locked current_locked, 46 struct vcpu **next); 47 void api_sri_send_if_delayed(struct vcpu *current); 48 49 struct ffa_value api_ffa_msg_send(ffa_id_t sender_vm_id, 50 ffa_id_t receiver_vm_id, uint32_t size, 51 struct vcpu *current, struct vcpu **next); 52 struct ffa_value api_ffa_msg_send2(ffa_id_t sender_vm_id, uint32_t flags, 53 struct vcpu *current); 54 struct ffa_value api_ffa_rx_release(ffa_id_t receiver_id, struct vcpu *current); 55 struct ffa_value api_ffa_rx_acquire(ffa_id_t receiver_id, struct vcpu *current); 56 struct ffa_value api_vm_configure_pages( 57 struct mm_stage1_locked mm_stage1_locked, struct vm_locked vm_locked, 58 ipaddr_t send, ipaddr_t recv, uint32_t page_count, 59 struct mpool *local_page_pool); 60 struct ffa_value api_ffa_rxtx_map(ipaddr_t send, ipaddr_t recv, 61 uint32_t page_count, struct vcpu *current); 62 struct ffa_value api_ffa_rxtx_unmap(ffa_id_t allocator_id, 63 struct vcpu *current); 64 struct ffa_value api_yield(struct vcpu *current, struct vcpu **next, 65 struct ffa_value *args); 66 struct ffa_value api_ffa_version(struct vcpu *current, 67 uint32_t requested_version); 68 struct ffa_value api_ffa_partition_info_get(struct vcpu *current, 69 const struct ffa_uuid *uuid, 70 const uint32_t flags); 71 bool api_ffa_fill_partition_info_from_regs( 72 struct ffa_value ret, uint16_t start_index, 73 struct ffa_partition_info *partitions, uint16_t partitions_len, 74 ffa_vm_count_t *ret_count); 75 struct ffa_value api_ffa_partition_info_get_regs(struct vcpu *current, 76 const struct ffa_uuid *uuid, 77 const uint16_t start_index, 78 const uint16_t tag); 79 struct ffa_value api_ffa_id_get(const struct vcpu *current); 80 struct ffa_value api_ffa_spm_id_get(void); 81 struct ffa_value api_ffa_feature_success(uint32_t arg2); 82 struct ffa_value api_ffa_features(uint32_t function_or_feature_id, 83 uint32_t input_property, 84 struct vcpu *current); 85 struct ffa_value api_ffa_msg_wait(struct vcpu *current, struct vcpu **next, 86 struct ffa_value *args); 87 struct ffa_value api_ffa_run(ffa_id_t vm_id, ffa_vcpu_index_t vcpu_idx, 88 struct vcpu *current, struct vcpu **next); 89 struct ffa_value api_ffa_mem_send(uint32_t share_func, uint32_t length, 90 uint32_t fragment_length, ipaddr_t address, 91 uint32_t page_count, struct vcpu *current); 92 struct ffa_value api_ffa_mem_retrieve_req(uint32_t length, 93 uint32_t fragment_length, 94 ipaddr_t address, uint32_t page_count, 95 struct vcpu *current); 96 struct ffa_value api_ffa_mem_relinquish(struct vcpu *current); 97 struct ffa_value api_ffa_mem_reclaim(ffa_memory_handle_t handle, 98 ffa_memory_region_flags_t flags, 99 struct vcpu *current); 100 struct ffa_value api_ffa_mem_frag_rx(ffa_memory_handle_t handle, 101 uint32_t fragment_offset, 102 ffa_id_t sender_vm_id, 103 struct vcpu *current); 104 struct ffa_value api_ffa_mem_frag_tx(ffa_memory_handle_t handle, 105 uint32_t fragment_length, 106 ffa_id_t sender_vm_id, 107 struct vcpu *current); 108 struct ffa_value api_ffa_msg_send_direct_req(ffa_id_t sender_vm_id, 109 ffa_id_t receiver_vm_id, 110 struct ffa_value args, 111 struct vcpu *current, 112 struct vcpu **next); 113 struct ffa_value api_ffa_msg_send_direct_req2(ffa_id_t sender_vm_id, 114 ffa_id_t receiver_vm_id, 115 struct ffa_value args, 116 struct vcpu *current, 117 struct vcpu **next); 118 struct ffa_value api_ffa_msg_send_direct_resp(ffa_id_t sender_vm_id, 119 ffa_id_t receiver_vm_id, 120 struct ffa_value args, 121 struct vcpu *current, 122 struct vcpu **next); 123 struct ffa_value api_ffa_msg_send_direct_resp2(ffa_id_t sender_vm_id, 124 ffa_id_t receiver_vm_id, 125 struct ffa_value args, 126 struct vcpu *current, 127 struct vcpu **next); 128 struct ffa_value api_ffa_secondary_ep_register(ipaddr_t entry_point, 129 struct vcpu *current); 130 struct vcpu *api_switch_to_other_world(struct vcpu_locked current_locked, 131 struct ffa_value other_world_ret, 132 enum vcpu_state vcpu_state); 133 struct ffa_value api_ffa_notification_bitmap_create(ffa_id_t vm_id, 134 ffa_vcpu_count_t vcpu_count, 135 struct vcpu *current); 136 struct ffa_value api_ffa_notification_bitmap_destroy(ffa_id_t vm_id, 137 struct vcpu *current); 138 139 struct ffa_value api_ffa_notification_update_bindings( 140 ffa_id_t sender_vm_id, ffa_id_t receiver_vm_id, uint32_t flags, 141 ffa_notifications_bitmap_t notifications, bool is_bind, 142 struct vcpu *current); 143 144 struct ffa_value api_ffa_notification_set( 145 ffa_id_t sender_vm_id, ffa_id_t receiver_vm_id, uint32_t flags, 146 ffa_notifications_bitmap_t notifications, struct vcpu *current); 147 148 struct ffa_value api_ffa_notification_get(ffa_id_t receiver_vm_id, 149 uint16_t vcpu_id, uint32_t flags, 150 struct vcpu *current); 151 152 struct ffa_value api_ffa_notification_info_get(struct vcpu *current); 153 154 struct ffa_value api_ffa_mem_perm_get(vaddr_t base_addr, struct vcpu *current); 155 struct ffa_value api_ffa_mem_perm_set(vaddr_t base_addr, uint32_t page_count, 156 uint32_t mem_perm, struct vcpu *current); 157 158 void api_flush_log_buffer(struct vcpu_locked *vcpu_locked); 159 struct ffa_value api_ffa_console_log(const struct ffa_value args, 160 struct vcpu *current); 161 162 void api_ffa_resume_direct_resp_target(struct vcpu_locked current_locked, 163 struct vcpu **next, 164 ffa_id_t receiver_vm_id, 165 struct ffa_value to_ret, 166 bool is_nwd_call_chain); 167 168 bool api_extended_args_are_zero(struct ffa_value *args); 169