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 | |
Karl Meakin | 117c808 | 2024-12-04 16:03:28 +0000 | [diff] [blame^] | 14 | struct ffa_value ffa_notifications_is_bitmap_access_valid(struct vcpu *current, |
| 15 | ffa_id_t vm_id); |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 16 | |
Karl Meakin | 117c808 | 2024-12-04 16:03:28 +0000 | [diff] [blame^] | 17 | bool ffa_notifications_is_bind_valid(struct vcpu *current, ffa_id_t sender_id, |
| 18 | ffa_id_t receiver_id); |
| 19 | bool ffa_notifications_update_bindings_forward( |
Karl Meakin | f9c73ce | 2024-07-30 17:37:13 +0100 | [diff] [blame] | 20 | ffa_id_t receiver_id, ffa_id_t sender_id, |
| 21 | ffa_notification_flags_t flags, ffa_notifications_bitmap_t bitmap, |
| 22 | bool is_bind, struct ffa_value *ret); |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 23 | |
Karl Meakin | 117c808 | 2024-12-04 16:03:28 +0000 | [diff] [blame^] | 24 | bool ffa_notifications_is_set_valid(struct vcpu *current, ffa_id_t sender_id, |
| 25 | ffa_id_t receiver_id); |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 26 | |
Karl Meakin | 117c808 | 2024-12-04 16:03:28 +0000 | [diff] [blame^] | 27 | bool ffa_notifications_set_forward(ffa_id_t sender_vm_id, |
| 28 | ffa_id_t receiver_vm_id, |
| 29 | ffa_notification_flags_t flags, |
| 30 | ffa_notifications_bitmap_t bitmap, |
| 31 | struct ffa_value *ret); |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 32 | |
Karl Meakin | 117c808 | 2024-12-04 16:03:28 +0000 | [diff] [blame^] | 33 | bool ffa_notifications_is_get_valid(struct vcpu *current, ffa_id_t receiver_id, |
| 34 | ffa_notification_flags_t flags); |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 35 | |
Karl Meakin | 117c808 | 2024-12-04 16:03:28 +0000 | [diff] [blame^] | 36 | struct ffa_value ffa_notifications_get_from_sp( |
Karl Meakin | f9c73ce | 2024-07-30 17:37:13 +0100 | [diff] [blame] | 37 | struct vm_locked receiver_locked, ffa_vcpu_index_t vcpu_id, |
| 38 | ffa_notifications_bitmap_t *from_sp); |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 39 | |
Karl Meakin | 117c808 | 2024-12-04 16:03:28 +0000 | [diff] [blame^] | 40 | struct ffa_value ffa_notifications_get_framework_notifications( |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 41 | struct vm_locked receiver_locked, ffa_notifications_bitmap_t *from_fwk, |
Karl Meakin | f9c73ce | 2024-07-30 17:37:13 +0100 | [diff] [blame] | 42 | ffa_notification_flags_t flags, ffa_vcpu_index_t vcpu_id); |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Creates a bitmap for the VM of the given ID. |
| 46 | */ |
Karl Meakin | 117c808 | 2024-12-04 16:03:28 +0000 | [diff] [blame^] | 47 | struct ffa_value ffa_notifications_bitmap_create(ffa_id_t vm_id, |
| 48 | ffa_vcpu_count_t vcpu_count); |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 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 | */ |
Karl Meakin | 117c808 | 2024-12-04 16:03:28 +0000 | [diff] [blame^] | 55 | bool ffa_notifications_bitmap_create_call(ffa_id_t vm_id, |
| 56 | ffa_vcpu_count_t vcpu_count); |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 57 | |
| 58 | /** |
| 59 | * Destroys the notifications bitmap for the given VM ID. |
| 60 | */ |
Karl Meakin | 117c808 | 2024-12-04 16:03:28 +0000 | [diff] [blame^] | 61 | struct ffa_value ffa_notifications_bitmap_destroy(ffa_id_t vm_id); |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 62 | |
| 63 | /** |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 64 | * Helper to send SRI and safely update `ffa_sri_state`, if there has been |
| 65 | * a call to FFA_NOTIFICATION_SET, and the SRI has been delayed. |
| 66 | * To be called at a context switch to the NWd. |
| 67 | */ |
Karl Meakin | 117c808 | 2024-12-04 16:03:28 +0000 | [diff] [blame^] | 68 | void ffa_notifications_sri_trigger_if_delayed(struct cpu *cpu); |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | * Helper to send SRI and safely update `ffa_sri_state`, if it hasn't been |
| 72 | * delayed in call to FFA_NOTIFICATION_SET. |
| 73 | */ |
Karl Meakin | 117c808 | 2024-12-04 16:03:28 +0000 | [diff] [blame^] | 74 | void ffa_notifications_sri_trigger_not_delayed(struct cpu *cpu); |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 75 | |
| 76 | /** |
| 77 | * Track that in current CPU there was a notification set with delay SRI flag. |
| 78 | */ |
Karl Meakin | 117c808 | 2024-12-04 16:03:28 +0000 | [diff] [blame^] | 79 | void ffa_notifications_sri_set_delayed(struct cpu *cpu); |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 80 | |
| 81 | /** |
| 82 | * Initialize Schedule Receiver Interrupts needed in the context of |
| 83 | * notifications support. |
| 84 | */ |
Karl Meakin | 117c808 | 2024-12-04 16:03:28 +0000 | [diff] [blame^] | 85 | void ffa_notifications_sri_init(struct cpu *cpu); |
Karl Meakin | 7a664f6 | 2024-07-24 17:20:29 +0100 | [diff] [blame] | 86 | |
Karl Meakin | 117c808 | 2024-12-04 16:03:28 +0000 | [diff] [blame^] | 87 | void ffa_notifications_info_get_forward(uint16_t *ids, uint32_t *ids_count, |
| 88 | uint32_t *lists_sizes, |
| 89 | uint32_t *lists_count, |
| 90 | uint32_t ids_count_max); |