Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2024 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/vm.h" |
| 12 | |
| 13 | struct ffa_value plat_ffa_is_notifications_bitmap_access_valid( |
| 14 | struct vcpu *current, ffa_id_t vm_id); |
| 15 | |
| 16 | bool plat_ffa_is_notifications_bind_valid(struct vcpu *current, |
| 17 | ffa_id_t sender_id, |
| 18 | ffa_id_t receiver_id); |
| 19 | bool plat_ffa_notifications_update_bindings_forward( |
| 20 | ffa_id_t receiver_id, ffa_id_t sender_id, uint32_t flags, |
| 21 | ffa_notifications_bitmap_t bitmap, bool is_bind, struct ffa_value *ret); |
| 22 | |
| 23 | bool plat_ffa_is_notification_set_valid(struct vcpu *current, |
| 24 | ffa_id_t sender_id, |
| 25 | ffa_id_t receiver_id); |
| 26 | |
| 27 | bool plat_ffa_notification_set_forward(ffa_id_t sender_vm_id, |
| 28 | ffa_id_t receiver_vm_id, uint32_t flags, |
| 29 | ffa_notifications_bitmap_t bitmap, |
| 30 | struct ffa_value *ret); |
| 31 | |
| 32 | bool plat_ffa_is_notification_get_valid(struct vcpu *current, |
| 33 | ffa_id_t receiver_id, uint32_t flags); |
| 34 | |
| 35 | bool plat_ffa_notifications_get_from_sp(struct vm_locked receiver_locked, |
| 36 | ffa_vcpu_index_t vcpu_id, |
| 37 | ffa_notifications_bitmap_t *from_sp, |
| 38 | struct ffa_value *ret); |
| 39 | |
| 40 | bool plat_ffa_notifications_get_framework_notifications( |
| 41 | struct vm_locked receiver_locked, ffa_notifications_bitmap_t *from_fwk, |
| 42 | uint32_t flags, ffa_vcpu_index_t vcpu_id, struct ffa_value *ret); |
| 43 | |
| 44 | /** |
| 45 | * Creates a bitmap for the VM of the given ID. |
| 46 | */ |
| 47 | struct ffa_value plat_ffa_notifications_bitmap_create( |
| 48 | ffa_id_t vm_id, ffa_vcpu_count_t vcpu_count); |
| 49 | |
| 50 | /** |
| 51 | * Issues a FFA_NOTIFICATION_BITMAP_CREATE. |
| 52 | * Returns true if the call goes well, and false if call returns with |
| 53 | * FFA_ERROR_32. |
| 54 | */ |
| 55 | bool plat_ffa_notifications_bitmap_create_call(ffa_id_t vm_id, |
| 56 | ffa_vcpu_count_t vcpu_count); |
| 57 | |
| 58 | /** |
| 59 | * Destroys the notifications bitmap for the given VM ID. |
| 60 | */ |
| 61 | struct ffa_value plat_ffa_notifications_bitmap_destroy(ffa_id_t vm_id); |
| 62 | |
| 63 | /** |
| 64 | * Helper to get the struct notifications, depending on the sender's id. |
| 65 | */ |
| 66 | struct notifications *plat_ffa_vm_get_notifications_senders_world( |
| 67 | struct vm_locked, ffa_id_t sender_id); |
| 68 | |
| 69 | bool plat_ffa_notification_info_get_call(struct ffa_value *ret); |
| 70 | |
| 71 | /** |
| 72 | * Helper to send SRI and safely update `ffa_sri_state`, if there has been |
| 73 | * a call to FFA_NOTIFICATION_SET, and the SRI has been delayed. |
| 74 | * To be called at a context switch to the NWd. |
| 75 | */ |
| 76 | void plat_ffa_sri_trigger_if_delayed(struct cpu *cpu); |
| 77 | |
| 78 | /** |
| 79 | * Helper to send SRI and safely update `ffa_sri_state`, if it hasn't been |
| 80 | * delayed in call to FFA_NOTIFICATION_SET. |
| 81 | */ |
| 82 | void plat_ffa_sri_trigger_not_delayed(struct cpu *cpu); |
| 83 | |
| 84 | /** |
| 85 | * Track that in current CPU there was a notification set with delay SRI flag. |
| 86 | */ |
| 87 | void plat_ffa_sri_set_delayed(struct cpu *cpu); |
| 88 | |
| 89 | /** |
| 90 | * Initialize Schedule Receiver Interrupts needed in the context of |
| 91 | * notifications support. |
| 92 | */ |
| 93 | void plat_ffa_sri_init(struct cpu *cpu); |
| 94 | |
| 95 | void plat_ffa_notification_info_get_forward(uint16_t *ids, uint32_t *ids_count, |
| 96 | uint32_t *lists_sizes, |
| 97 | uint32_t *lists_count, |
| 98 | uint32_t ids_count_max); |