Daniel Boulby | b2fb80e | 2021-02-03 15:09:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021 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/ffa.h" |
Olivier Deprez | 55a189e | 2021-06-09 15:45:27 +0200 | [diff] [blame] | 12 | #include "hf/vcpu.h" |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 13 | #include "hf/vm.h" |
Daniel Boulby | b2fb80e | 2021-02-03 15:09:23 +0000 | [diff] [blame] | 14 | |
Daniel Boulby | 87b2dc8 | 2021-08-04 14:07:43 +0100 | [diff] [blame] | 15 | /** Returns information on features that are specific to the platform. */ |
| 16 | struct ffa_value plat_ffa_features(uint32_t function_id); |
Daniel Boulby | b2fb80e | 2021-02-03 15:09:23 +0000 | [diff] [blame] | 17 | /** Returns the SPMC ID. */ |
| 18 | struct ffa_value plat_ffa_spmc_id_get(void); |
Olivier Deprez | 55a189e | 2021-06-09 15:45:27 +0200 | [diff] [blame] | 19 | |
| 20 | void plat_ffa_log_init(void); |
| 21 | void plat_ffa_init(bool tee_enabled); |
| 22 | bool plat_ffa_is_direct_request_valid(struct vcpu *current, |
| 23 | ffa_vm_id_t sender_vm_id, |
| 24 | ffa_vm_id_t receiver_vm_id); |
| 25 | bool plat_ffa_is_direct_response_valid(struct vcpu *current, |
| 26 | ffa_vm_id_t sender_vm_id, |
| 27 | ffa_vm_id_t receiver_vm_id); |
| 28 | bool plat_ffa_direct_request_forward(ffa_vm_id_t receiver_vm_id, |
| 29 | struct ffa_value args, |
| 30 | struct ffa_value *ret); |
J-Alves | a0f317d | 2021-06-09 13:31:59 +0100 | [diff] [blame] | 31 | bool plat_ffa_is_notifications_create_valid(struct vcpu *current, |
| 32 | ffa_vm_id_t vm_id); |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 33 | |
| 34 | bool plat_ffa_is_notifications_bind_valid(struct vcpu *current, |
| 35 | ffa_vm_id_t sender_id, |
| 36 | ffa_vm_id_t receiver_id); |
J-Alves | b15e940 | 2021-09-08 11:44:42 +0100 | [diff] [blame] | 37 | bool plat_ffa_notifications_update_bindings_forward( |
| 38 | ffa_vm_id_t receiver_id, ffa_vm_id_t sender_id, uint32_t flags, |
| 39 | ffa_notifications_bitmap_t bitmap, bool is_bind, struct ffa_value *ret); |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 40 | |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 41 | bool plat_ffa_is_notification_set_valid(struct vcpu *current, |
| 42 | ffa_vm_id_t sender_id, |
| 43 | ffa_vm_id_t receiver_id); |
| 44 | |
J-Alves | de7bd2f | 2021-09-09 19:54:35 +0100 | [diff] [blame] | 45 | bool plat_ffa_notification_set_forward(ffa_vm_id_t sender_vm_id, |
| 46 | ffa_vm_id_t receiver_vm_id, |
| 47 | uint32_t flags, |
| 48 | ffa_notifications_bitmap_t bitmap, |
| 49 | struct ffa_value *ret); |
| 50 | |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 51 | bool plat_ffa_is_notification_get_valid(struct vcpu *current, |
| 52 | ffa_vm_id_t receiver_id); |
| 53 | |
J-Alves | 98ff956 | 2021-09-09 14:39:41 +0100 | [diff] [blame] | 54 | bool plat_ffa_notifications_get_from_sp(struct vm_locked receiver_locked, |
| 55 | ffa_vcpu_index_t vcpu_id, |
| 56 | ffa_notifications_bitmap_t *from_sp, |
| 57 | struct ffa_value *ret); |
| 58 | |
J-Alves | aa79c01 | 2021-07-09 14:29:45 +0100 | [diff] [blame] | 59 | bool plat_ffa_notifications_get_call(ffa_vm_id_t receiver_id, uint32_t vcpu_id, |
| 60 | uint32_t flags, struct ffa_value *ret); |
| 61 | |
Olivier Deprez | 55a189e | 2021-06-09 15:45:27 +0200 | [diff] [blame] | 62 | /** |
Maksims Svecovs | 9ddf86a | 2021-05-06 17:17:21 +0100 | [diff] [blame] | 63 | * Checks whether managed exit is supported by given SP. |
| 64 | */ |
| 65 | bool plat_ffa_vm_managed_exit_supported(struct vm *vm); |
| 66 | |
| 67 | /** |
Olivier Deprez | 55a189e | 2021-06-09 15:45:27 +0200 | [diff] [blame] | 68 | * Encodes memory handle according to section 5.10.2 of the FF-A v1.0 spec. |
| 69 | */ |
| 70 | ffa_memory_handle_t plat_ffa_memory_handle_make(uint64_t index); |
| 71 | |
| 72 | /** |
| 73 | * Checks whether given handle was allocated by current world, according to |
| 74 | * handle encoding rules. |
| 75 | */ |
| 76 | bool plat_ffa_memory_handle_allocated_by_current_world( |
| 77 | ffa_memory_handle_t handle); |
Maksims Svecovs | b596eab | 2021-04-27 00:52:27 +0100 | [diff] [blame] | 78 | |
| 79 | /** |
| 80 | * Return the FF-A partition info VM/SP properties given the VM id. |
| 81 | */ |
| 82 | ffa_partition_properties_t plat_ffa_partition_properties( |
| 83 | ffa_vm_id_t current_id, const struct vm *target); |
J-Alves | 4ef6e84 | 2021-03-18 12:47:01 +0000 | [diff] [blame] | 84 | |
| 85 | /** |
| 86 | * Initializes the NWd VM structures for Notifications support. |
| 87 | */ |
| 88 | void plat_ffa_vm_init(void); |
J-Alves | a0f317d | 2021-06-09 13:31:59 +0100 | [diff] [blame] | 89 | |
| 90 | /** |
| 91 | * Get NWd VM's structure. |
| 92 | */ |
| 93 | struct vm_locked plat_ffa_vm_find_locked(ffa_vm_id_t vm_id); |
| 94 | |
| 95 | /** |
| 96 | * Creates a bitmap for the VM of the given ID. |
| 97 | */ |
| 98 | struct ffa_value plat_ffa_notifications_bitmap_create( |
| 99 | ffa_vm_id_t vm_id, ffa_vcpu_count_t vcpu_count); |
| 100 | |
| 101 | /** |
J-Alves | a9c7cba | 2021-08-25 16:26:11 +0100 | [diff] [blame] | 102 | * Issues a FFA_NOTIFICATION_BITMAP_CREATE. |
| 103 | */ |
| 104 | bool plat_ffa_notifications_bitmap_create_call(ffa_vm_id_t vm_id, |
| 105 | ffa_vcpu_count_t vcpu_count, |
| 106 | struct ffa_value *ret); |
| 107 | |
| 108 | /** |
J-Alves | a0f317d | 2021-06-09 13:31:59 +0100 | [diff] [blame] | 109 | * Destroys the notifications bitmap for the given VM ID. |
| 110 | */ |
| 111 | struct ffa_value plat_ffa_notifications_bitmap_destroy(ffa_vm_id_t vm_id); |
J-Alves | c003a7a | 2021-03-18 13:06:53 +0000 | [diff] [blame] | 112 | |
| 113 | /** |
| 114 | * Helper to get the struct notifications, depending on the sender's id. |
| 115 | */ |
| 116 | struct notifications *plat_ffa_vm_get_notifications_senders_world( |
| 117 | struct vm_locked vm_locked, ffa_vm_id_t sender_id); |
| 118 | |
| 119 | /** |
| 120 | * Helper to check if FF-A ID is a VM ID. |
| 121 | */ |
| 122 | bool plat_ffa_is_vm_id(ffa_vm_id_t vm_id); |
Raghu Krishnamurthy | 62f97a7 | 2021-07-27 02:14:59 -0700 | [diff] [blame] | 123 | |
| 124 | /** |
| 125 | * Forward normal world calls of FFA_RUN ABI to other world. |
| 126 | */ |
| 127 | bool plat_ffa_run_forward(ffa_vm_id_t vm_id, ffa_vcpu_index_t vcpu_idx, |
| 128 | struct ffa_value *ret); |
J-Alves | c8e8a22 | 2021-06-08 17:33:52 +0100 | [diff] [blame] | 129 | |
| 130 | bool plat_ffa_notification_info_get_call(struct ffa_value *ret); |
| 131 | |
| 132 | bool plat_ffa_vm_notifications_info_get(uint16_t *ids, uint32_t *ids_count, |
| 133 | uint32_t *lists_sizes, |
| 134 | uint32_t *lists_count, |
| 135 | const uint32_t ids_count_max); |
Raghu Krishnamurthy | ea6d25f | 2021-09-14 15:27:06 -0700 | [diff] [blame^] | 136 | |
| 137 | bool plat_ffa_is_mem_perm_get_valid(const struct vcpu *current); |
| 138 | bool plat_ffa_is_mem_perm_set_valid(const struct vcpu *current); |