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