blob: 24471e617418778df7dace35d860a25a7f3b0ccb [file] [log] [blame]
Karl Meakin7a664f62024-07-24 17:20:29 +01001/*
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 Meakinf9c73ce2024-07-30 17:37:13 +010011#include "hf/ffa.h"
Karl Meakin7a664f62024-07-24 17:20:29 +010012#include "hf/vm.h"
13
14struct ffa_value plat_ffa_is_notifications_bitmap_access_valid(
15 struct vcpu *current, ffa_id_t vm_id);
16
17bool plat_ffa_is_notifications_bind_valid(struct vcpu *current,
18 ffa_id_t sender_id,
19 ffa_id_t receiver_id);
20bool plat_ffa_notifications_update_bindings_forward(
Karl Meakinf9c73ce2024-07-30 17:37:13 +010021 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 Meakin7a664f62024-07-24 17:20:29 +010024
25bool plat_ffa_is_notification_set_valid(struct vcpu *current,
26 ffa_id_t sender_id,
27 ffa_id_t receiver_id);
28
29bool plat_ffa_notification_set_forward(ffa_id_t sender_vm_id,
Karl Meakinf9c73ce2024-07-30 17:37:13 +010030 ffa_id_t receiver_vm_id,
31 ffa_notification_flags_t flags,
Karl Meakin7a664f62024-07-24 17:20:29 +010032 ffa_notifications_bitmap_t bitmap,
33 struct ffa_value *ret);
34
35bool plat_ffa_is_notification_get_valid(struct vcpu *current,
Karl Meakinf9c73ce2024-07-30 17:37:13 +010036 ffa_id_t receiver_id,
37 ffa_notification_flags_t flags);
Karl Meakin7a664f62024-07-24 17:20:29 +010038
Karl Meakinf9c73ce2024-07-30 17:37:13 +010039struct 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 Meakin7a664f62024-07-24 17:20:29 +010042
Karl Meakinf9c73ce2024-07-30 17:37:13 +010043struct ffa_value plat_ffa_notifications_get_framework_notifications(
Karl Meakin7a664f62024-07-24 17:20:29 +010044 struct vm_locked receiver_locked, ffa_notifications_bitmap_t *from_fwk,
Karl Meakinf9c73ce2024-07-30 17:37:13 +010045 ffa_notification_flags_t flags, ffa_vcpu_index_t vcpu_id);
Karl Meakin7a664f62024-07-24 17:20:29 +010046
47/**
48 * Creates a bitmap for the VM of the given ID.
49 */
50struct 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 */
58bool 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 */
64struct ffa_value plat_ffa_notifications_bitmap_destroy(ffa_id_t vm_id);
65
66/**
Karl Meakin7a664f62024-07-24 17:20:29 +010067 * 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 */
71void 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 */
77void 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 */
82void plat_ffa_sri_set_delayed(struct cpu *cpu);
83
84/**
85 * Initialize Schedule Receiver Interrupts needed in the context of
86 * notifications support.
87 */
88void plat_ffa_sri_init(struct cpu *cpu);
89
90void 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);