blob: 95a82c83713ac3ec1fb30d5bb806e6d1e4296bae [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
Karl Meakin117c8082024-12-04 16:03:28 +000014struct ffa_value ffa_notifications_is_bitmap_access_valid(struct vcpu *current,
15 ffa_id_t vm_id);
Karl Meakin7a664f62024-07-24 17:20:29 +010016
Karl Meakin117c8082024-12-04 16:03:28 +000017bool ffa_notifications_is_bind_valid(struct vcpu *current, ffa_id_t sender_id,
18 ffa_id_t receiver_id);
19bool ffa_notifications_update_bindings_forward(
Karl Meakinf9c73ce2024-07-30 17:37:13 +010020 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 Meakin7a664f62024-07-24 17:20:29 +010023
Karl Meakin117c8082024-12-04 16:03:28 +000024bool ffa_notifications_is_set_valid(struct vcpu *current, ffa_id_t sender_id,
25 ffa_id_t receiver_id);
Karl Meakin7a664f62024-07-24 17:20:29 +010026
Karl Meakin117c8082024-12-04 16:03:28 +000027bool 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 Meakin7a664f62024-07-24 17:20:29 +010032
Karl Meakin117c8082024-12-04 16:03:28 +000033bool ffa_notifications_is_get_valid(struct vcpu *current, ffa_id_t receiver_id,
34 ffa_notification_flags_t flags);
Karl Meakin7a664f62024-07-24 17:20:29 +010035
Karl Meakin117c8082024-12-04 16:03:28 +000036struct ffa_value ffa_notifications_get_from_sp(
Karl Meakinf9c73ce2024-07-30 17:37:13 +010037 struct vm_locked receiver_locked, ffa_vcpu_index_t vcpu_id,
38 ffa_notifications_bitmap_t *from_sp);
Karl Meakin7a664f62024-07-24 17:20:29 +010039
Karl Meakin117c8082024-12-04 16:03:28 +000040struct ffa_value ffa_notifications_get_framework_notifications(
Karl Meakin7a664f62024-07-24 17:20:29 +010041 struct vm_locked receiver_locked, ffa_notifications_bitmap_t *from_fwk,
Karl Meakinf9c73ce2024-07-30 17:37:13 +010042 ffa_notification_flags_t flags, ffa_vcpu_index_t vcpu_id);
Karl Meakin7a664f62024-07-24 17:20:29 +010043
44/**
45 * Creates a bitmap for the VM of the given ID.
46 */
Karl Meakin117c8082024-12-04 16:03:28 +000047struct ffa_value ffa_notifications_bitmap_create(ffa_id_t vm_id,
48 ffa_vcpu_count_t vcpu_count);
Karl Meakin7a664f62024-07-24 17:20:29 +010049
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 Meakin117c8082024-12-04 16:03:28 +000055bool ffa_notifications_bitmap_create_call(ffa_id_t vm_id,
56 ffa_vcpu_count_t vcpu_count);
Karl Meakin7a664f62024-07-24 17:20:29 +010057
58/**
59 * Destroys the notifications bitmap for the given VM ID.
60 */
Karl Meakin117c8082024-12-04 16:03:28 +000061struct ffa_value ffa_notifications_bitmap_destroy(ffa_id_t vm_id);
Karl Meakin7a664f62024-07-24 17:20:29 +010062
63/**
Karl Meakin7a664f62024-07-24 17:20:29 +010064 * 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 Meakin117c8082024-12-04 16:03:28 +000068void ffa_notifications_sri_trigger_if_delayed(struct cpu *cpu);
Karl Meakin7a664f62024-07-24 17:20:29 +010069
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 Meakin117c8082024-12-04 16:03:28 +000074void ffa_notifications_sri_trigger_not_delayed(struct cpu *cpu);
Karl Meakin7a664f62024-07-24 17:20:29 +010075
76/**
77 * Track that in current CPU there was a notification set with delay SRI flag.
78 */
Karl Meakin117c8082024-12-04 16:03:28 +000079void ffa_notifications_sri_set_delayed(struct cpu *cpu);
Karl Meakin7a664f62024-07-24 17:20:29 +010080
81/**
82 * Initialize Schedule Receiver Interrupts needed in the context of
83 * notifications support.
84 */
Karl Meakin117c8082024-12-04 16:03:28 +000085void ffa_notifications_sri_init(struct cpu *cpu);
Karl Meakin7a664f62024-07-24 17:20:29 +010086
Karl Meakin117c8082024-12-04 16:03:28 +000087void 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);